views:

24

answers:

2

I have been profiling javascript on my page that uses dojo widgets. I don't use explicit parsing - the parser runs on page load.

What I noticed is that if I clear browser cache before refreshing the page, dojo parsing takes much more time than if all the files are already cached.

Note that we build all the required dojo modules into a layer (a single file), so we don't lazy-load any js files.

I wonder if dojo parsing process depends on images and css resources, as far as I know it only instantiates widgets and injects dom nodes.

Do you have any ideas why dojo parser runs longer (2-3 times longer in my case) when the cache is cleared?

+1  A: 

Did you check if any files are loaded? Locales? NLS? Date/time parsing/formatting is highly culture-dependent, which can be resolved dynamically by locales, unless you did a proper build listing supported locales.

Eugene Lazutkin
I watched files downloading with HttpAnalyzer - there were only images, css files and a single js layer file. So as I understand from your answer, parsing shouldn't depend on css, image resources?
Kniganapolke
That's correct, parsing does not uses images nor CSS.
Eugene Lazutkin
You were right. I missed some nls files that were loading. There also were some template files that didn't get built into the layer.
Kniganapolke
those nls files should be loaded prior to the parse and the culture-dependent code should not be impacted by caching. Perhaps the images or css downloaded in parallel are slowing everything down?
peller
+1  A: 

It sounds like the page load itself, not the parsing, would be slower if the cache is cleared, and that's no different from any other page. You can minimize CSS a bit with the build tool. The cssOptimize setting can inline all the @import files for Dijit the way it concatenates CSS, if you're not already doing that. Images can be tiled also to help with performance.

peller
What was confusing to me was that javascript profiler showed longer time for dojo's parse method to execute when cache was cleared.
Kniganapolke