Coder Social home page Coder Social logo

Semicolons about history.js HOT 7 CLOSED

dmnc avatar dmnc commented on August 26, 2024
Semicolons

from history.js.

Comments (7)

balupton avatar balupton commented on August 26, 2024

This is kind of a duplicate of: #46

This is kind of outside the scope of History.js - the files are compressed with Buildr + UglifyJS which omits the end-of-file semi-colon in the compressed versions of the file. Buildr also supports bundling too, you can change the "buildr" part in the package.json file to:

"buildr": {
    "compress": {
        "js": true,
        "css": false,
        "img": false,
        "html": false
    },
    "check": {
        "js": true,
        "jsOptions": {
            "browser": true,
            "laxbreak": true,
            "boss": true,
            "undef": true,
            "onevar": true,
            "strict": true
        }
    },
    "ignore": {
        "check": [
            "json2.js",
            "amplify.store.js"
        ]
    },
    "bundle": {
        "js": "history.all.js",
        "css": false
    },
    "directories": {
        "out": "./scripts/compressed",
        "src": "./scripts/uncompressed"
    },
    "files": {
        "js": [
            "amplify.store.js",
            "history.adapter.jquery.js",
            "history.js"
        ],
        "css": false,
        "img": false
    }
}

and that will bundle the mentioned js files into a history.all.js file. Or I'd say that in your bundling script, it should be adding semicolons between files.

Though with closure and uglify I've never had an issue bundling. Here is also a php script that I've used to bundle with closure: https://github.com/balupton/balphp/blob/master/lib/Bal/View/Helper/HeadScriptBundler.php#L77

from history.js.

deleteme avatar deleteme commented on August 26, 2024

Related UglifyJS Issue: mishoo/UglifyJS#126 (comment)

Because I am including history js as a git submodule and inlining the minified files, I had to do this in my HAML:

%script
  -# inlining minified libraries
  -# having to insert a few missing semicolons.
  = render :file => 'public/javascripts/lib/history/scripts/compressed/history.adapter.zepto.js'
  \;
  = render :file => 'public/javascripts/lib/history/scripts/compressed/history.js'
  \;
  = render :file => 'public/javascripts/lib/history/scripts/compressed/history.html4.js'
  \;

Google Closure preserves the trailing semicolon for this reason. I am not sure what other minification libraries do.

It would be nice if the minified files were immediately usable, otherwise, why provide them at all?

from history.js.

balupton avatar balupton commented on August 26, 2024

I've got a question. Does the bundler you're using also minify? If so, just include the uncompressed scripts...

It would be nice if the minified files were immediately usable, otherwise, why provide them at all?

They are individually, which is actually what the majority of people do :/

from history.js.

deleteme avatar deleteme commented on August 26, 2024

I have a rake script that watches my javascript files for changes, runs it through yui's compressor, and then outputs a minified file in a different directory. I could update it to consider the uncompressed history.js javascript, but then I lose the benefit of having a git submodule to manage the library.

from history.js.

balupton avatar balupton commented on August 26, 2024

... how would it affect git submodules? Both the uncompressed and compressed are in the same git repo...

from history.js.

Sinetheta avatar Sinetheta commented on August 26, 2024

Yup, still causing pain.

from history.js.

Angelinsky7 avatar Angelinsky7 commented on August 26, 2024

Yes, still causing pain in 2017...

from history.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.