mercredi 13 septembre 2017

How to structure JavaScript loading and deps?

I have lots of JavaScript on site, including jQuery, jQuery UI (autocomplete), ads, social widgets, internal scripts, metrics (like GA) and so on. I would like to structure how resources are being loaded (from top priority to the lowest):

  • jQuery & jQuery UI to enable auto-complete;
  • internal scripts;
  • ads;
  • metrics;
  • social widgets.

Currently I moved all the scripts to the bottom and loading them async (except for jQuery as it isn't handling ONLOAD properly if async-loaded). I would like to load all JS stuff after the content, but I would like for it to be loaded in specific order.

What is an industry-grade solution for the task?




Aucun commentaire:

Enregistrer un commentaire