I work with a sandboxed solution which is deployed in a .wsp file. The solution mostly contains our webparts. The pages that contains these webparts, are slow at startup, but it seems that there is some caching, because the next time the page is opened, it goes faster.

Our webparts contains js and css, so I thought it would be a good idea to seperate all the styling and js into seperate files and include these files.

As I have searched for information about this issue, I have understood that using customAction is the best way to include/refernce the css and js files. But my question is, will this make the loading of the pages faster?

You can put the JS and CSS into separate file and upload it to Style Library of the website [if to be used in single site] or to _layouts folder [if to be used across sites].. But this has nothing to do with slow loading! And Custom Action is very different from all these, where did you read that?
–
Arsalan Adam KhatriNov 22 '12 at 14:47

3 Answers
3

I wouldn't be at all sure JS and CSS file loading is causing the slowness. Try using Developer Dashboard, YSlow, Fiddler, Firebug, or other tools to determine what is causing the slowness.

Blobcache will cache the files properly, provided that it is enabled (see web.config). Also make sure it is configured to cache JS and CSS files (should be by default) - finally make sure you see some content added to the blobcache folder to verify it is really working. You can also confirm that using Fiddler.

You can also minimize JS and CSS files to make them smaller, and ensure GZIP is enabled in IIS for these (assuming they're under _layouts).

Finally, dynamically loading Javascript might be a good idea, see this for example on how to load file only when user clicks on a link.