We recently created a view that used teasers for nodes, which didn't have the maps showing (excluded from the Display settings). However, the Javascript srcs to Google and Bing were still being added. That's fine, but when we have a view with ten nodes, and then each layer for Google and Bing, we were having about 70 includes for the script. Obviously... this slowed down page performance. So, here's a little patch that'll help things out.
The patch creates a few static variables, and only includes the scripts on the first time around.
(Patch to be included in reply so I can use the issue number in it)
Comment | File | Size | Author |
---|---|---|---|
#1 | openlayers-809208.patch | 5.18 KB | mikesir87 |
Comments
Comment #1
mikesir87 CreditAttribution: mikesir87 commentedPatch is attached.
Comment #2
tmcw CreditAttribution: tmcw commentedGood catch, and the patch looks solid. I'll test briefly and commit.
Comment #3
zzolo CreditAttribution: zzolo commented@mikesir87 good catch. It is because we have to utilize drupal_set_html_head() which does not do any sort of checking or overwriting. Does it make sense to provide a help function for this? All you would need is a function that takes an ID with the JS to include.
Comment #4
mikesir87 CreditAttribution: mikesir87 commented@zzolo sure! that could definitely work. would you like me to make one up, or will you handle it?
Comment #5
tmcw CreditAttribution: tmcw commentedNot terribly opposed to the idea of encapsulating it, but I think that it might be making the layer type prototype more complex for an incomplete win - I'd imagine that there are also cases in which commercial layers are including, say, two javascript files, or a css file, in the same pattern but with different code. This would be the perfect place for a ruby-style block input, but alas this is PHP, and I'm not sure that this is the best idea.
Comment #6
tmcw CreditAttribution: tmcw commentedCommitted in its current form: http://drupal.org/cvs?commit=372508
We can open a ticket for refactoring if needed? Anyway, I wanted to get this in so that a refactor can be tested against it, and we don't have lots of uncommitted patches.