Performance (or other) benefit to adding CSS and JS files in a .info file rather than tpl?


Yes, the JavaScript cannot be aggregated meaning that instead of asking for a single (few) css/js files, the browser will have to ask for more files which is slower and required more work of your web server.

Depeding on how many JS and CSS files you add in your page.tpl.php you can get a noticeable performance improvement using the .info file method. It's also a lot better should you need to use your theme as a base theme, since it allows for better alters of the JS/CSS files.

Similar questions

Getting .info file not found in my custom module, even though it does contain an .info file
I am trying to install my custom module, but the error I get is: modulename.tar.gz does not contain any .info files. My module tar.gz file does indeed contain a .info file. I have installed other modules on the server, so I shouldn't have any permission issues. The following is the content of the .info file.
Difference between 2 methods of adding a CSS files in
What is the different between these 2 methods of loading a CSS files? Method 1 means the CSS file is loaded further down the page head, which I need for my theme. However from looking at the documentation it seems Method 2 is more standard?
Is there any way to force https:// to be used for assets and still be able to define a theme CSS files in its .info file?
I have a theme which defines its CSS files in its .info file, for example with a line like the following. The site is accessed using https://, but for some reason, Drupal tries to load all the files via http://. Is there any way to force Drupal to use https:// on assets and still be able to define a theme CSS files in its .info file?
How can I attach an existing server image to an image field rather than uploading a new image file?
Is there a module or some other way of attaching an image to an image field by selecting the image from existing files on the server rather than upload a new image? I'm working on a project where many nodes have an image field. That image is displayed in various places at different sizes using image styles. The users are migrating from another syst...
How can I automatically upload images on file selection rather than pressing the upload button?
I have a custom content type to allow users to upload images. I'm trying to keep the interface as simple as possible. The content type contains a single image field. This works, but some users don't understand that the image has been uploaded because they don't see it after selecting (to preview the upload, the upload button must be pressed). Is th...
Features - branch 2.x results in large info files that exceed the 'info' column limit in the 'system' table
Original thread on DO (will keep it up to date) Hello. I am currently developing a mid-to-large project. As i've done before, but using the 1.x branch, I use Features to track all structural and functional components of my site in order to be able to transfer them from my local installation, to the staging server, to the production server etc, whil...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.