biow0lf / evedev-kb

Automatically exported from code.google.com/p/evedev-kb
1 stars 0 forks source link

Javascript library loading #157

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What is the enhancement you would like to see?
I would like to see a system for loading javascript libraries such as jQuery 
from CDN, so that mods do not try to load multiple copies.

What steps would use of your enhancement involve?
1. modify class.page.php to allow mods to load libraries if they are not 
already loaded.
I have attached a modified class.page.php as a suggestion.

Please provide any additional information below.
This came to mind as I was thinking of using jQuery to enhance my mods and got 
to wondering how it could be loaded. I was particularly worried about multiple 
copies of the same library being loaded.

Original issue reported on code.google.com by vascowhite on 10 Aug 2011 at 5:35

Attachments:

GoogleCodeExporter commented 9 years ago
I forgot to mention my changes are at line 24 and lines 76 to 93

Original comment by vascowhite on 10 Aug 2011 at 5:37

GoogleCodeExporter commented 9 years ago
Since EDK doesn't use those libraries, I don't think it makes sense to hardcode 
them in the core. It would make it easier to be sure all mods using that 
library used the same version, but do you really want to depend on someone that 
doesn't even use the library to decide what is there?

For now you would be better off using Page::addHeader() to add the script line. 
You will get multiple copies if multiple mods add their script, but so far this 
is not a problem.

Longer term, would adding getHeaders() be enough? You could then use string 
functions to search for 'jquery', for example, to see if the library was loaded.

If there's any more demand for an EDK-specified set of libraries, such as your 
code has, I don't mind adding it, I just have doubts about how well maintained 
it would be. *Any* more demand. ;)

Original comment by kovellia on 11 Aug 2011 at 12:08

GoogleCodeExporter commented 9 years ago
"Longer term, would adding getHeaders() be enough?"

Yes, I think that would probably do the job. So long as there is a way of 
checking what is already loaded I suppose. Would that make it into 3.3?

Original comment by vascowhite on 11 Aug 2011 at 11:01

GoogleCodeExporter commented 9 years ago
Yes, 3.3. Or 4.0, whichever is next.

I'm actually leaning back to having some libraries specified in the core now. 
^^ If there's going to be a problem with mods wanting different versions of a 
library, it's actually more likely if the version is chosen by which mod loads 
first. So it's probably more helpful to have the core specify the version, even 
if it's out of date.

So, are there any other libraries common enough to include?

Original comment by kovellia on 11 Aug 2011 at 11:48

GoogleCodeExporter commented 9 years ago
I'm not sure what other mod devs would want to see, but for me I think jquery 
would be the main one. I haven't used any others to any great extent, but maybe 
prototype and dojo would be worth thinking about.

Maybe it would be a question for you to ask in the mod section of the forum?

I don't think the libraries need to be included unless requested by a mod if 
such a mechanism can be set up. I agree that the core should specify the 
version of the library that is loaded. This all depends on mods being well 
behaved ofcourse :)

I don't think there is any harm in more niche libraries being included with the 
mod as there is less likelyhood of duplication.

Original comment by vascowhite on 11 Aug 2011 at 12:41

GoogleCodeExporter commented 9 years ago
Added this with r1486. I'll add any other to it library if there's demand and 
it seems useful enough.

Original comment by kovellia on 11 Aug 2011 at 1:19

GoogleCodeExporter commented 9 years ago
Quick work, thanks.

Original comment by vascowhite on 11 Aug 2011 at 1:33