using jQuery and then search for addtional plugins over the course of a year. <script src=“/share/jquery/jquery.min.js”></script> <script src=“/share/jquery/jquery.cookie.min.js”></script> <script src=“/share/jquery/jquery.purl.min.js”></script> <script src=“/share/jquery/jquery.datepicker.min.js”></script> <script src=“/share/jquery/jquery.easing.min.js”></script> This sucks because browsers (might) make multiple connections to load all these. Browsers will also need to delay execution as it waits for all the chunks to come in completely. Lets optimise this by compiling these down to 1 file instead, down to 1 big chunk it can just grab and go.
we had a bunch of .js files sitting in the share/jquery directory. Create share/jquery/src – move jquery.min.js into this folder. Create share/jquery/src/libs – move all the other jQuery plugins into there. Create share/jquery/dist – move all jQuery CSS files, Images, and any other plugin resources into there. This prepares the directory to build a OneScript project. Lets pretend our project is in /opt/website with the public webroot of /opt/website/www. This means we now have: /opt/website/www/share/jquery/src/jquery.min.js /opt/website/www/share/jquery/src/libs/jquery.cookie.min.js ... And the rest of the plugins in libs as well.
create www/share/jquery \ --outfile=jquery-et-al.js \ --files=jquery.min.js This will create the the share/jquery/onescript.json file which defines the project. In this file you will see jquery.min.js listed in the main Files array, which it will pull from the src directory. You will also see the libs directory listed in the Directories array, which it will find in the src directory. It will search the libs directory for all files with the .js file extension, as foretold by the Extensions array in the project file.
www/share/jquery Assuming there are no errors this will generate your jquery-et-al.js file from jQuery and all the plugins you have in the libs diretory. Any time you add or update an additional jQuery or a plugin, just rerun this command to regenerate the final file. The final build file will have been placed in the dist directory.
calls, replacing them with one single script – the final builid. <script src=“/share/jquery/dist/jquery-et-al.js”></script> Update any references to the CSS files that the plugins needed as well, since I told you to move the styles and resources to the dist folder.