Dojo implementation loading new version JS Library

Source: Internet
Author: User

After using dojo has been tangled JS file content has updated how to load, these two days finally solved the problem, originally want to add a library file instead of dojo corresponding function, but found that the dojo library apparitions too tight, on the original file changed.

Load in two cases one dojo.text! load or no code execution, and the other is loaded as a library, and the two are handled separately.


The first is to add the version number "? V=xxx" directly after the loaded URL.

Tourl = Req.tourl = function (name, referencemodule) {var moduleinfo = GetModuleInfo (name+ "x", Referencemodule), url= Moduleinfo.url;            Url=url.substring (0, url.length-5)            if (req.version) {                URL + = "?" +req.version;                name+= "?" +req.version;            } Return Fixupurl (moduleinfo.pid===0//If pid===0, then name had a protocol or absolute path; either to, Tourl is the IDE ntify function in such casesname://"/x.js" since GetModuleInfo automatically appends ". js" and we appended "/X" to make Name look like a module idurl//url.substring (0, url.length-5));

The other is to add the version number "? V=xxx" when loading the library file.

Compactpath = function (path) {            var p=path;var result = [],segment, Lastsegment;path = Path.replace (/\\/g, '/'). Split ( '/'); while (path.length) {segment = Path.shift (); if (segment== ":" && result.length && lastsegment!= "...") {Result.pop (); lastsegment = Result[result.length-1];} else if (segment!= ".") {Result.push (lastsegment= segment);} else ignore "."}            var url=result.join ("/");            if (P.indexof ('/x.js ') ==-1 && req.version && p.indexof ('. js ')!=-1) {                url+= "?" +req.version;                Console.log (' Compactpath result: ', path,result);            } return URL;},




Add the Version property to the Require library when you use it.

require.version= ' v0.1 ';


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.