Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Js片段 #3

Closed
ilife5 opened this issue Apr 23, 2013 · 0 comments
Closed

Js片段 #3

ilife5 opened this issue Apr 23, 2013 · 0 comments

Comments

@ilife5
Copy link
Owner

ilife5 commented Apr 23, 2013

js引入

seajs异步载入代码

;(function(m, o, d, u, l, a, r) {
  if(m[o]) return
  function f(n) { return function() { r.push(n, arguments); return a } }
  m[o] = a = { args: (r = []), config: f(1), use: f(2), on: f(3) }
  m.define = f(0)
  u = d.createElement("script")
  u.id = o + "node"
  u.async = true
  u.src = "path/to/sea.js"
  l = d.getElementsByTagName("head")[0]
  l.appendChild(u)
})(window, "seajs", document);

匹配url中path部分的最后一个路径部分

/:\/\/.*\/([^/?#]*)((?=[?#])|$)/

创造一个cache

var CACHELENGTH = 10000;

function createCache() {
    var cache,
        keys = [];

    return (cache = function( key, value ) {
        if ( keys.push( key ) > CACHELENGTH ) {
            delete cache[ keys.shift() ];
        }
        return (cache[ key ] = value);
    });
}
@ilife5 ilife5 closed this as completed Sep 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant