I always ask myself next questions, if somebody can answer one of them, please reply me.
- Unless there's no conflict between scrpits, can I put as much script as I want? (I mean by much, 3~5 times as much than most of wikia sites, for example.)
- Some scripts that I'm using is destinated to affect only elements on the main page. Are these scripts loaded on every article load? I'm afraid they make the site slow or so.
- Does the following two codes do same thing on wikia sites?
- Theoretically yes, but generally JS libraries like jQuery consume more memory on the user part. You could compare the performances of alternatives (built–in DOM handler vs. jQuery vs. something else) on websites like jsPerf.
- If not wrapped in a conditional, yes.
- Yes, the latter is a shorthand for the former AFAIK.
- TK999 20:52, July 4, 2012 (UTC)
- 3) Yes. TK is right. Rappy 20:55, July 4, 2012 (UTC)
- That depends a little on your definition of "much". How many lines of code are you talking about? 100? 1000? 10000? More?
- If they're in your MediaWiki:Common.js then yes. If you put your homepage's code into a separate file in the MediaWiki namespace and surround it with <script> tags, then you could verbatim it into the main page. The verbatim tag is undocumented, but you can see it in action on this wiki's main page.
- -- pecos 21:00, July 04, 2012 (UTC)
- @TK-999 and Rappy -- Thank you. And then, can I use head.js to speed up the page loading? I'm not sure whether this kind of things are supported by wikia.
- I don't know how many lines they will do, but how about 50kbyte in optimized version?
- I see that. I've already tried <verbatim> for a twitter widget, but I didn't know what this was for. I'll think about verbatim my scripts. Thank you.
- Cafeinlove msg 2012/7/5, 06:11 (KST), 21:11 (UTC)
- 50K is larger than jQuery and exactly as large as jQuery UI. In other words: Its' an awful lot. What library are you loading and are you absolutely sure you need it? -- pecos 21:29, July 04, 2012 (UTC)
There is no way the MediaWiki software could impose a size limit on your JS code. In that sense you're perfectly safe. It's the load-time of your page you should be worried about. Browsers are funny about JS. When they encounter JS they drop everything else and download and parse the JS first. That's the pitfall. -- pecos 22:14, July 04, 2012 (UTC)