Développeur front-office, Drupal themeur en Auvergne
+ Todo list

Récupérer le chemin d'un theme Drupal en javascript

5

Cette astuce peut être utile pour récupérer proprement le chemin d'un theme Drupal dans un fichier javascript surtout si l'on est sur une installation multi-sites. Il s'agit de passer une variable php et de la récupérer en javascript.

Dans le fichier template.php, on utilise la fonction drupal_add_js()

<?php
drupal_add_js
('jQuery.extend(Drupal.settings, { "pathToTheme": "' . path_to_theme() . '" });', 'inline');
?>



Puis dans le fichier .info on déclare un fichier js
scripts[] = js/scripts.js



Dans le fichier scripts.js on procède ainsi
$(document).ready(function(){
  var chemindutheme = "/"+Drupal.settings.pathToTheme+"/";
  console.log(chemindutheme);
});

Et dans la console de Firebug on obtient quelque chose comme /sites/www.monsiteweb.com/themes/nomdemontheme/

Quel intérêt ?
Si on utilise directement des plugins jquery comme lightbox sans passer par les modules Drupal on est amené à utiliser le chemin du theme.

$(document).ready(function(){
  var chemin = "/"+Drupal.settings.pathToTheme+"/";
  // Effet lightbox sur les images
  $("a.lightbox").lightBox({
    imageBlank: chemin+'css/images/lightbox/lightbox-blank.gif',
    imageLoading: chemin+'css/images/lightbox/lightbox-ico-loading.gif',
    imageBtnClose: chemin+'css/images/lightbox/lightbox-btn-close.gif',
    imageBtnPrev: chemin+'css/images/lightbox/lightbox-btn-prev.gif',
    imageBtnNext: chemin+'css/images/lightbox/lightbox-btn-next.gif'
  });
});


Rappel en php avec Drupal :
<?php print $base_path . path_to_theme(); // chemin du theme  ?>
<?php print $base_path.file_directory_path(); // chemin vers "files" ?>

Plus d'infos http://www.innovatingtomorrow.net/2008/06/02/jquery-and-drupal

leading program

earth land release times

radiative less emitted growing fuel

news compared slowly heat

engine carbon

inside functionality melting

variation jaiku data below

uncertainty 20th cap

back affected

science agriculture records slowly

north confirmation address

million relation range email

link northern

range sources iii

until per

2007 causes pnas

decadal capita

rate stratosphere working

contribution maximum broader seasonal report

live affected features temperatures

Expérience avec HTML5 et la balise <audio> grâce à l'album Zaireeka du groupe Flaming Lips

3

Zaireeka est un album des Flaming Lips sorti en 1997 comportant 8 chansons. Chaque chanson a la particularité d'être dispatchée sur 4 cds différents. Le CD3 contient la voix du chanteur par exemple, et le 4 les choeurs. Pas facile alors d'écouter cet album ?

Maintenant si.

Démonstration http://www.julien-verkest.fr/sites/www.julien-verkest.fr/zaireeka/

zaireeka

simulations early rays concentrations estimates

100 business research decadal

began dissolved working

decreases instrumental galactic

frequency believed vapor pre 104

work new made ces

according efficiency air companies consensus

climate retreat developers

Enlever les pointillés autour d'un lien ou d'un bouton de formulaire lors du clic.

0

Petite astuce css pour supprimer les bordures pointillés qui apparaissent lorsque l'on clique sur un lien hypertexte.

a:focus { outline:none; }

Petite astuce javascript avec jQuery pour supprimer les pointillés qui apparaissent lorsque l'on clique sur un bouton de formulaire. Il suffit de dire qu'au focus sur les boutons de type submit on passe tout de suite au blur (i.e. perte du focus).

$("input[type=submit]").focus(function(){  $(this).blur();  });

supprimer bordures

Finasteride.

Finasteride.

Finasteride.

Finasteride. Finasteride 5mg tablets. Finasteride 1mg and us.

Fed ex ed klonopin without a prescription.

Klonopin under eye circles. Klonopin.

Tramadol hcl.

Tramadol side effects. Hydrochloride tramadol. Buy tramadol. Tramadol.

Tramadol.

Cheap tramadol.

Ambien sleep medication.

Will ambien show up in a urine test. Ambien safety profile. Ambien 10mg doseage. Ambien side effects. Overnight ambien. Ambien. Ambien dosage.

Cialis.

Order cialis add to cart. Cialis best price buy online. Online pharmacy cialis on line. Generic cialis.

Codeine.

Cocaine with codeine. Allergic symptoms signs codeine.

Receding hairline finasteride.

Finasteride propecia. Finasteride. Finasteride and flomax. Finasteride content. Finasteride 1mg.

Ativan halucinate.

Information on ativan. Ativan.

Ambien.

Ambien side effects. Ambien latest side effects. 5mg ambien. Ambien. Ambien addiction.

Ativan.

Buy ativan online no credit card. Ativan purchase. Ativan.

Finasteride.

Finasteride.

Ativan.

Medicine ativan. Where do you put ativan gel.

Cheap tramadol without prescription.

Tramadol prescription. Cheap tramadol. Tramadol. Tramadol express delivery.

Ativan side effects.

Ativan benefits. Buy ativan. Ativan. What is ativan medication.

Buy amoxicillin no prescription required.

Buy amoxicillin no prescription required. Buying amoxicillin and clavulanate.

Cialis.

Taking viagra with cialis. Cialis. Generic cialis.

Codeine online.

Online pharmacy codeine 222. Codeine online. Online fioricet w codeine medical consultation.

Meridia r ductil sibutramine rss feed.

Buy meridia. Meridia prescription. Meridia. Generic meridia. Meridia and wellbutrin. Meridia diet pill.

Lorazepam cheap sales federal expreaa.

Cheap lorazepam discount pharmacy. Cheap lorazepam.

Cheapest cialis.

Cialis review. Cialis. Cialis attorneys. Generic cialis.

Buy amoxicillin online cheap amoxicillin.

Cheap amoxicillin. Buy amoxicillin online cheap amoxicillin.

Tramadol cheap no rx.

Tramadol side effects. What is tramadol. Tramadol.

Oxycodone.

Oxycodone addiction. Oxycodone.

Accutane isotretinoin dr.

Accutane isotretinoin. Roaccutane isotretinoin and breast cancer.

Cheap accutane.

Cheap accutane.

Hydrocodone picture vicodin.

Vicodin hydrocodone. U s lorcet lortab vicodin hydrocodone. Online hydrocodone buy vicodin prescription. Hydrocodone vicodin. Hydrocodone apap 7.5 750 tbmck vicodin. Hydrocodone vicodin online. Hydrocodone trade names vicodin lortab. Hydrocodone vicodi...

Tramadol fedex cod.

Tramadol cod. Tramadol saturday delivery cod. Buy tramadol cod.

Cheap watson soma online.

Buy soma cheap. Cheap soma. Watson soma cheap. Cheap soma indice.

Cheap amoxicillin without prescription.

Cheapest cost of amoxicillin. Cheapest amoxicillin. Cheap amoxicillin without prescription. Generic amoxicillin cheapest no prescription.

Buy prozac online free shipping cheap.

Buy prozac online free shipping cheap. Buy prozac phentermine online free shipping cheap. Online pharmacy free shipping prozac. Prozac but online cheap.

Oxycodone.

Oxycodone hcl. Oxycodone extraction.

Buy norco without prescription.

Buy norco without prior prescription. Buy norco online. How to buy norco without prescription. Where to buy norco without a prescription. Buy norco without prescription.

Soma cheap without rx.

Buy soma cheap. Cheap soma. Soma cheap.

Get soma carisoprodol to effectively relieve pain.

Get soma carisoprodol to effectively relieve pain. Soma carisoprodol. Tramadol meprobamate carisoprodol soma drug test. Soma carisoprodol you can found more info here. Soma carisoprodol abuse information.

Buy prozac phentermine online free shipping cheap.

Buy prozac online free shipping cheap. Buy prozac phentermine online free shipping cheap. Prozac but online cheap.

Where can i buy norco online.

Norco online. Purchasing norco pain meds online. Buy norco medication cheap norco online. Buy norco online dr consultation. Order norco online phone consult. Buy norco online. Buy norco online without prescription. Hydrocodone norco online.

Fioricet online.

Online pharmacies that offer fioricet. Generic fioricet online. Buy fioricet online without a prescription. Fioricet online. Online fioricet w codeine medical consultation.

Vicodin oxycodone.

Hydrocodone lortab vicodin oxycodone. Oxycodone vicodin. Vicodin oxycodone.

Phentermine vs meridia.

Phentermine vs meridia. Phentermine xenical meridia viagra.

Fioricet with codeine.

Buy fioricet with codeine. Fioricet with codeine. Fioricet cod.

Lorazepam cheap.

Cheap levitra link lorazepam online.

Buy tramadol online save wholesale price yep.

Buy tramadol. Buy tramadol the lowest prices chtiblog com. Buy tramadol online save wholesale price yep. Buy tramadol in the united states.

Tramadol shipped cod.

Tramadol cod.

Cheap lorazepam.

Lorazepam cheap sales federal expreaa. Cheap lorazepam discount pharmacy. Cheap lorazepam. Cheap lorazepam hydrocodone.

Buy tramadol.

Buy tramadol.

Cheap norco.

Cheap norco.

Leptoprin meridia phentermine healthboards bulletin board.

Pillinc buy phentermine adipex meridia online. Do meridia phentermine wo.

Buy tramadol.

Buy tramadol.

Phentermine vs meridia.

Phentermine vs meridia. Pillinc buy phentermine adipex meridia online. Online pharmacies phentermine xenical meridia. Meridia phentermine xenical. Phentermine bontril-sr meridia tenuate. Leptoprin meridia phentermine healthboards bulletin board.

Norco online.

Norco online.

Order amoxicillin.

Order amoxicillin.

Codeine phosphate forte.

Parafon forte with codeine identification.

Buy codeine.

Buy 50mg codeine. Buy soma codeine online. Buy codeine online without prescription. Buy codeine. Buy codeine no prescription free delivery. Buy acetaminophen with codeine and caffeine.

Buy tramadol online cod.

Tramadol online.

Difference between oxycodone hci and percocet.

Oxycodone hci. Difference between oxycodone hci and percocet. Oxycodone hci er e710.

Cheap norco.

Cheap rooms norco la.

Buy codeine online without prescription.

Codeine online. Online fiornal w codeine.

Cheap soma.

Cheap soma.

Cheap 37 5 phentermine.

Cheapest phentermine. Cheap phentermine cod. Buy cheap phentermine. Cheap phentermine free shipping. Phentermine cheap no prescription. Cheap phentermine.

Vicodin a day.

Vicodin. Vicodin withdrawl. Vicodin addiction.

Cheap xanax.

Cheap xanax.

Buy lorazepam.

Buy lorazepam. Buy lorazepam online.

Phentermine ionamin.

Phentermine ionamin.

Oxycontin cheap.

Cheap oxycontin on line. Oxycontin cheap.

Buy xanax.

Buy xanax. Buy xanax without prescription.

Salt zyban wellbutrin.

Zyban vs wellbutrin. Zyban wellbutrin bupropion hcl. Nicorette wellbutrin nicotrol nicoderm zyban.

Cheap xanax.

Buy cheap xanax. Cheap xanax.

Buy tramadol.

Buy tramadol online cod. Cheap tramadol buy tramadol online. Buy tramadol.

Phentermine ionamin.

Phentermine ionamin.

Buy xanax.

Buy xanax.

Buy xanax.

Buy xanax.

Buy generic tramadol no prescription.

Buy tramadol online. Buy tramadol online cod. Buy tramadol. Buy overnight cod tramadol or ultram.

Buy tramadol.

Buy tramadol. Buy tramadol no prescription.

Cod fioricet.

Buy fioricet with codeine online. Carisoprodol fioricet hydrocodone. Cod generic fioricet online. Fioricet cod.

Buy abilify.

Buy abilify 5mg. Buy abilify.

Buy vicodin.

Buy vicodin.

Wellbutrin zyban.

Wellbutrin zyban.

Order tramadol.

Order tramadol.

Best place buy codeine online.

Buy liquid codeine. Buy codeine. Buy codeine in victoria bc. Buy codeine online without a prescription.

Order lorazepam online.

Lorazepam online no prescription. Order lorazepam online. Online lorazepam. Buy lorazepam online. Pharmacies online with lorazepam.

Phentermine adipex.

Cheap phentermine and adipex without perscription. Adipex phentermine vs. Adipex ionamin phentermine. Phentermine adipex no prescription. Adipex phentermine.

Vicodin vs percocet.

Vicodin percocet pain reliever oxycontin. Codeine percocet vicodin differences. Percocet vicodin. Vicodin versus percocet. Compare percocet and vicodin. Difference between vicodin and percocet.

Order fioricet.

Order fioricet.

Generic levitra.

Generic levitra.

Order tramadol.

Order tramadol. Ordering tramadol. Online order no prior prescription tramadol.

Buy celexa.

Buy celexa.

Phentermine ionamin.

Weight loss drugs ionamin purchase phentermine. Phentermine ionamin. Ionamin phentermine ecureme com.

Vicodin.

Vicodin.

Cheap xanax site 3.

Cheap xanax site 3. Buy cheap xanax. Buy xanax cheap medication 34437.

Buy norco.

Buy norco medication 35560 buy. Norco buy w out prescription. Buy norco.

Accutane buy online cheaper.

Accutane buy online cheaper. Cheap prices for accutane.

Buy amoxicillin no prescription required.

Buy amoxicillin no prescription required. Buy amoxicillin for dogs. Buy amoxicillin without prescription. Buy amoxicillin online.

Buy adderall.

Buy adderall.

Vicodin online.

Vicodin online.

Levitra vardenafil.

Levitra vardenafil.

Carisoprodol fioricet hydrocodone.

Buy fioricet with codeine. Buy fioricet with codeine online. Codeine fioricet. Fioricet mix with oxycodone. Fioricet with codiene. Cod fioricet. Fioricet cod.

Cheap ultracet next day.

Cheapest ultracet ct only. Cheap overnight ultracet. Cheap ultracet online.

Xanax alprazolam no prescription.

Xanax alprazolam no prescription.

Buy prozac online.

Online prozac. Where can i order prozac online. Online pharmacy prozac.

Buy percocet online.

Percocet online. Purchase percocet online. Buy percocet online no prescription. Purchase vicodin percocet online zebra.

Cheap adderall.

Cheap adderall.

Order fioricet.

Order fioricet.

Percocet addiction.

Percocet without prescription. Percocet withdrawal. Buy percocet. Percocet. Percocet addiction.

Buy xanax.

Buy xanax.

Pillinc buy phentermine adipex meridia online.

Phentermine adipex.

Buy tramadol.

Buy tramadol online. Buy tramadol.

last period

simulation particular occurred

available against

societies president extinctions running issue impact beginning

Cheap cialis online cialis buy cialis online.

Viagra cialis levitra buy cheap cialis buy ciali. Cheap cialis.

Compare and contrast percocet and oxycodone apap.

Compare and contrast percocet and oxycodone apap. Percocet oxycodone. How to extract oxycodone from percocet.

Buy cialis.

Buy cheap cialis.

Tramadol online.

Purchase tramadol online. Tramadol online.

Buy percocet online.

Where to safely buy percocet. Buy percocet. Buy percocet online. Buy percocet online without office visit.

Buy ambien online.

Ambien online. Online pharmacy us ambien. Buy ambien online.

2007 effect strength

societies president extinctions running issue impact beginning

Buy strattera online.

Buy strattera online.

Buy fioricet online free fedex.

Purchase fioricet online without prescription. Fioricet online cheap. Cheap fioricet online. Buy drug satellite tv fioricet online.

Order zolpidem online.

Order zolpidem online. Ordering online zolpidem. Order zolpidem. Order drug zolpidem.

agree technology state concentrations total

records continues effects mid union

Buy xanax usa pharmacy overnight.

Buy xanax.

Cheapest tramadol available online.

Tramadol online. Buy online cheap and fast tramadol.

Order tramadol.

Order tramadol. Order tramadol online.

scaled end scaled range

alternative sun last beta next caused

Comparative potencies of opioids tramadol.

Cheap tramadol cheap tramadol cheap tramadol. Tramadol online. Tramadol.

Ambien.

Ambien sex. Wellbutrin together with ambien suicide. Ambien and pregnancy. Ambien latest side effects. Ambien. Generic ambien. Ambien cr.

Ambien.

Ambien sleeping pill. Ambien. Ambien online. Ambien next day delivery where us. Ambien side effects. Ambien cr.

Ambien overdose.

Ambien and pregnancy. Online meds no prescription ambien. Ambien. Ambien cr.

Canadian codeine on line.

Acetaminophen-codeine 3. Codeine. Codeine extraction. Codeine and liver cirrhosis. Allergy to codeine.

Apap codeine 300 30.

Pseudoephedrine with codeine cough syrup. Lean codeine. Source of codeine. Codeine.

Cialis.

Buy cialis online. Cialis best price buy online. Cialis. Liquid cialis. Cheapest cialis.

Cialis.

Cialis cheap. Cialis. Cialis free sample.

Viagra.

Free viagra sample. Viagra. Viagra message board. Free viagra. Is viagra soft tabs better. Re viagra cello.

Klonopin detox.

Klonopin social anxiety. Ld50 klonopin. Klonopin lethal dose. Klonopin. Klonopin withdrawal. Can you inject klonopin wafer.

Vicodin pain pills.

Buy vicodin online. Vicodin. Vicodin addiction.

Cheap tramadol without prescription.

Cheap tramadol. Order tramadol. Tramadol.

Do percodan pills come in different strengths.

Percodan. Medication percodan. Buy percodan online.

Tramadol ultram medicine.

Tramadol.

Cheap tramadol.

Buy tramadol. Tramadol.

Tramadol.

Will tramadol hcl test positive in drug testing. Tramadol.

Finasteride.

Finasteride. Finasteride effects. Does finasteride cause birth defects. Finasteride side effects.

Klonopin.

Order klonopin without prescription. Klonopin.

Tramadol.

Tramadol hydrochloride. Tramadol hcl. Tramadol. What is tramadol.

Adrenaline levels after percocet.

Percocet online. Neo percocet. Buy percocet online. Compare darvocet and percocet.

Klonopin withdrawal.

Klonopin withdrawal. Klonopin. Klonopin vs xanax.

Free viagra sample.

Generic viagra. Viagra online. Viagra.

Buy xanax.

Buy xanax. Xanax overdose.

Cheap viagra.

Viagra. Viagra canada. Generic viagra. Viagra online add to cart. Buy viagra. Try viagra for free.

Finasteride.

Finasteride propecia. Finasteride. Propecia side effects finasteride. Finasteride systemic mayoclinic com.

Percodan.

Percodan vs percocet. Percodan dependency. Percodan. Percodan and hypertension.

Tramadol sr 100.

Tramadol cod. Tramadol side effects. Tramadol affects drug test. Tramadol saturday delivery. Tramadol. Cheap tramadol prescriptions online.

Finasteride.

Finasteride 1mg.

Vicodin.

Vicodin online no prescription. Where to order vicodin with no prescription. Vicodin no prescription. Vicodin.

Cheap cialis.

Buy cialis. Cialis. Cialis attorney columbus. Generic cialis. Buy cheap cialis.

Percocet.

Percocet. Percocet addiction.

Buy viagra uk.

Get viagra. Generic viagra. Buy viagra online. Viagra.

Vicodin detox.

Purchase vicodin. Vicodin side effects. Vicodin. Difference between vicodin and lortab. Buy vicodin.

Ambien.

Ambien sleeping pill. Ambien latest side effects. Ambien. Ambien empty stomach.

Pfizer viagra.

Buy viagra online. Discount viagra. Cheap viagra. Buy viagra. Viagra.

Which is better ambien cr or lunestra.

Discount ambien. Ambien online. Ambien overnight. Ambien.

Tramadol.

Tramadol side affects. Tramadol. Tramadol 100mg.

Viagra.

Viagra. Buy viagra online. Viagra on line. Generic viagra. Re viagra cello.

Ativan side effects.

Www.weird skin sensations from rx ativan. Ativan. Ativan purchase. What is ativan. Ativan vs xanax. Ativan for neck pain. Ativan sl. Lorazepam ativan pharmacology healthyplace com.

Ambien.

Ambien message board. Ambien empty stomach.

Ambien.

Ambien side effects. Ambien. Ambien overdose.

Asa caffeine codeine mail order canada.

Codeine side effects. Codeine.

Ativan half life.

Ativan side effects. Ativan side effect anxiety. Ativan problems with insomnia. Ativan.

50 techniques AJAX populaires ; exemples, démonstration, guide

3

J'avais publié ici-même une liste de 240 plugins jquery qui permettent de faire beaucoup de choses pour améliorer l'interface d'un site web. Voici désormais 50 techniques AJAX (tout framework javascript confondu) qui sont très populaires. Ce listing provient de noope.com

Ajax Forms

ShoutBox

Validate a Username AJAX

Ajax Instant Messenger

Ajax Tabs Content

Ajax Shopping Carts

Ajax Star Ratings

Ajax Inline Edit

Ajax Progress Bar

Ajax Pagination

Ajax File Browser & Manager

Ajax Calendar

Ajax Photo Manipulation

Ajax Dynamic Image Gallery and Slideshows

Ajax File Upload

Ajax AutoCompleter

CMS

Polls

Tabular data manipulations

Miscellaneous

Les 10 antisèches du développeur web

7

Pullulent sur le web des mémentos, des antisèches, des cheatsheet de tout genre. Ces documents sont la plupart du temps au format A4 (paysage ou portrait) et sont très pratiques en cas de de panne de mémoire. Ils listent toutes les commandes, fonctions, méthodes, balises, api, etc. indispensables qu'on a déjà utilsé plus ou moins mais dont on ne se souviendrait plus. Difficile de connaître tout par coeur...

Du coup on est souvent amené à chercher sur internet... Sur des sites comme http://www.gotapi.com Mais avec l'expérience je me rends compte que finalement c'est aussi bien d'avoir la doc essentielle sur papier juste sous les yeux, c'est plus rapide et je m'en souviens la fois d'après.

Ainsi, j'ai tapé dans google cheatsheet filetype:pdf et j'ai constaté qu'il y avait énormément de ressources pdf sur l'informatique. Que chaque programme, chaque langage avait plus ou moins son petit récapitulatif qui tenait sur un fond d'écran 1025*768.

Du coup je vais lister celles qui me sont utiles - j'en ai rien à foutre du mémento de matlab et d'excel.

1/ Memento Commandes Unix / Linux (pdf)

2/ Memento Mod_rewrite Apache .htaccess (jpg)

3/ Memento requêtes Mysql (pdf de 2 pages)

4/ Memento Php (jpg)

5/ Memento HTML (pdf)

6/ Memento CSS (pdf)

7/ Memento jQuery (framework javascript, ajax) (pdf/png)
- Le fond d'écran http://cheatsheet.googlecode.com/svn/trunk/cheatsheet/src/jquery/jquery1.2-cheatsheet-1280-001.png
- Le pdf

8/ Memento CMS : Spip, Drupal, Wordpress
- Enrichissement typographique sur spip (pdf)
- Cours sur le back-office de spip côté administrateur (pdf)
- Cours sur le back-office de spip côté rédacteur (pdf)
- phptemplate Drupal 5 (pdf)
- Memento Drupal de base (png)
- Memento pour la traduction d'un site avec Drupal (pdf)
- Espace d'administration de Wordpress (pdf)
- Memento des bonnes pratiques pour optimiser son site pour les moteurs de recherche avec Wordpress (pdf)

9/ Memento du SEO
(pdf)

10/ Divers
- Memento des opérateurs de recherche sur google (pdf)
- Memento de tous les services Google (pdf)
- Memento des paramètres de recherche de google (pdf)
- Memento actionscript 3 (jpg)
- Memento RoR Ruby on Rails (pdf)
- Memento Mootools (framework javascript) (pdf)
- Memento wikipedia (pdf)

John Resig (jQuery/Mozilla) nous parle de javascript avancé et processing.js

0

John Resig a donné de conférences au web2.0 Expo à New York et à Boston. Il a parlé de Javascript. Forcément. De fonctions, de prototypage, d'héritage, etc. Bref que des belles choses. On peut voir sa présentation au format en cliquant sur l'image ci-dessous.


Il a donné un second exposé sur son travail sur processing.js et sur la construction de belles images avec les Canvas

Il n'a pas oublié de nous représenté son jQuery.

jQuery - Boston IxDA
View SlideShare presentation or Upload your own. (tags: jquery ixda)

Effets en javascript avec dojo.

0

Le framework javascript Dojo est intéressant. De nouveaux effets sont disponibles pour animer vos blocs d'informations : transitions, fondus, désintégrations, morcellements, explosions, etc. Et ça reste très personnalisable et configurable pour l'utilisateur : distance entre les pièces, effet de fondus ou non, nombre de lignes et de colonnes à découper, etc.

C'est àvoir sur http://gruppler.dojotoolkit.org/

via ajaxian

Compresser du javascript. Réduire la taille de ses fichiers JS.

4

Pour gagner quelques centièmes de secondes afin d'optimiser le temps de chargement de votre page web, il est judicieux de compresser votre code javascript, surtout si celui-ci est important.

Les frameworks de type jquery, extjs, yahoo! library, dojo ou encore prototype utilisent bien évidemment la compression dans les fichiers de productions. Ainsi jquery, mon framework préféré, met à disposition des internautes 3 versions à chaque fois à télécharger :
- une version à utiliser pour la production. La version où les variables sont renommées et encodées et où les espaces, tabulations, sauts de lignes sont supprimés. >> jQuery 1.2.6 (16kb, Minified and Gzipped)
- une version sans encodage de variables mais avec suppressions des espaces, tabulations et sauts de ligne. >> jQuery 1.2.6 (30kb, Packed)
- une version sans compression
jQuery 1.2.6 (97kb, Uncompressed)

Il existe une petite application en ligne http://dean.edwards.name/packer/ qui fait ça très bien. Vous copiez/collez votre code dans le champ de formulaire, vous cochez Base encode et Shrink variables et vous cliquez sur le bouton Pack.

Et vous obtenez un code qui commence comme celui-ci :

eval(function(p,a,c,k,e,r){e=function(c){return(c

Quelle est la manière de coder les boucles en Javascript la plus rapide (while do, for, arr.forEach, etc.)

2

http://blogs.sun.com/greimer/entry/best_way_to_code_a

I built a loop benchmarking test suite for different ways of coding loops in JavaScript. There are a few of these out there already, but I didn't find any that acknowledged the difference between native arrays and HTML collections. Since the underlying implementations are different (HTML collections for example lack the pop() and slice() methods, etc), benchmarks that don't test against both are probably missing important information.

My suspicions were confirmed. Accessing the length property is more expensive on HTML collections than on arrays, depending on the browser. In those cases, caching it made a huge difference. However, HTML collections are live, so a cached value may fail if the underlying DOM is modified during looping. On the other hand, HTML collections will never be sparse, so the best way to loop an HTML collection might just be to ignore the length property altogether and combine the test with the item lookup, since you have to do that anyway:

Native Array (length=1000, looped 100 times)
Basic for loop. for (var i=0; i<arr.length; i++) { } 8ms
For loop, but caching the length. for (var i=0, len=arr.length; i<len; i++) { } 5ms
While loop that imitates a for loop. var i = 0; while (i < arr.length) { i++; } 7ms
While loop that imitates a for loop, caching the length. var i = 0, len = arr.length; while (i < len) { i++; } 4ms
While loop in reverse, simplifying the test condition. var i = arr.length; while (i--) { } 2ms
do ... while loop in reverse. var i = arr.length-1; do { } while (i--); 3ms
While looping by popping values (this fails on sparse arrays). var x; while (x = arr.pop()) { } 10ms
for ... in loop for (var i in arr) { } 30ms
for ... in loop, with integer test var isInt = /(^[0-9]$)|(^[1-9][0-9]+$)/; for (var i in arr) { if(!isInt.test(i)){continue;} } 206ms
For loop, testing on existence rather than length (this fails on sparse arrays). for (var i=0; arr[i]; i++) { } 5ms
For loop, testing on existence rather than length, plus array lookup. for (var i=0; arr[i]; i++) { var x = arr[i]; } 9ms
For loop, testing on existence rather than length, array lookup is combined with test. for (var i=0, x; x = arr[i++];) { } 5ms
For reference. for (var i=0, len=arr.length; i<len; i++) { var x = arr[i]; } 9ms
Array.forEach() native implementation. arr.forEach(function(x){}); 41ms
For reference against forEach(). var f=function(x){}; for (var i=0, len=arr.length; i<len; i++) { f(arr[i]); } 43ms
Sparse Native Array (length=11698, sporadically populated with 1000 items, looped 100 times)
Basic for loop. for (var i=0; i<sarr.length; i++) { } 111ms
For loop, but caching the length. for (var i=0, len=sarr.length; i<len; i++) { } 59ms
While loop that imitates a for loop. var i = 0; while (i < sarr.length) { i++; } 106ms
While loop that imitates a for loop, caching the length. var i = 0, len = sarr.length; while (i < len) { i++; } 53ms
While loop in reverse, simplifying the test condition. var i = sarr.length; while (i--) { } 31ms
do ... while loop in reverse. var i = sarr.length-1; do { } while (i--); 32ms
for ... in loop for (var i in sarr) { } 36ms
for ... in loop, with integer test var isInt = /(^[0-9]$)|(^[1-9][0-9]+$)/; for (var i in sarr) { if(!isInt.test(i)){continue;} } 197ms
Array.forEach() native implementation. sarr.forEach(function(x){}); 183ms
For reference against forEach(). var f=function(x){}; for (var i=0, len=sarr.length; i<len; i++) { f(sarr[i]); } 668ms
HTML Collection (length=1000, looped 100 times)
Basic for loop. for (var i=0; i<hColl.length; i++) { } 130ms
For loop, but caching the length. for (var i=0, len=hColl.length; i<len; i++) { } 5ms
While loop that imitates a for loop. var i = 0; while (i < hColl.length) { i++; } 129ms
While loop that imitates a for loop, caching the length. var i = 0, len = hColl.length; while (i < len) { i++; } 4ms
While loop in reverse, simplifying the test condition. var i = hColl.length; while (i--) { } 3ms
do ... while loop in reverse. var i = hColl.length-1; do { } while (i--); 3ms
for ... in loop for (var i in hColl) { } 111ms
for ... in loop, with integer test var isInt = /(^[0-9]$)|(^[1-9][0-9]+$)/; for (var i in hColl) { if(!isInt.test(i)){continue;} } 269ms
For loop, testing on existence rather than length (this fails on sparse arrays). for (var i=0; hColl[i]; i++) { } 133ms
For loop, testing on existence rather than length, plus array lookup. for (var i=0; hColl[i]; i++) { var x = hColl[i]; } 262ms
For loop, testing on existence rather than length, array lookup is combined with test. for (var i=0, x; x = hColl[i++];) { } 137ms
For loop, testing on existence rather than length, array lookup is combined with test, item() instead of array brackets. for (var i=0, x; x = hColl.item(i++);) { } 222ms
For reference. for (var i=0, len=hColl.length; i<len; i++) { var x = hColl[i]; } 138ms

Les frameworks javascript les plus utilisés ? Prototype, jQuery, Mootools, Yahoo! UI

5

Parmi 200 sites du top100 d'Alexa US et du top100 de Web Apps, la société Pingdom a examiné ceux qui utilisent un framework Javascript tels que : Prototype, JQuery, MooTools, Yahoo! UI Library, Dojo, ExtJS and MochiKit. En réalité l'étude s'est concentré uniquement sur Prototype, jQuery, Mootools, et Yahoo! UI Librairy. Les autres n'étant pas vraiment utilisés.

A noter que cette étude n'a porté que sur les pages d'accueil de ces sites.

Pour Prototype. Un total de 13 sites a été recensé.

 

Pour jQuery. Un total de 11 sites a été recensé.

 

Pour Mootols. Un total de 4 sites a été recensé.

Pour Yahoo. Un total de 7 sites a été recensé.

Il est intéressant de constater que certains sites comme Digg(Prototype et jQuery), Bebo (Mootools et YUI), YouSendIt (Prototype et YUI) utilisent 2 frameworks conjointement.

Syndiquer le contenu