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

change head.load api to pass attributes to loaded dom element #314

Closed
wants to merge 1 commit into from

Conversation

jaypea
Copy link

@jaypea jaypea commented Jun 26, 2014

As mentioned in #312 I would like to load a CSS file with media="print" attribute.
This PR is inspired by @robert-hoffmann comments in #262 (comment) and in #267 (comment)

It is now possible to add options to an asset. Implemented are additional attributes to the created DOM elements (link or script).

head.load({
           mylabel: "somescriptPath",
            options: {
                attributes: {
                    "data-main": "loaded1"
                }
            }
        },
       callback
);

I could not find any script to create the dist files, is there one?

@jaypea
Copy link
Author

jaypea commented Jun 26, 2014

btw, travis fails because this is a pull request from a fork and travis encrypted env variables do not support this. travis fails on grunt settting up saucelabs and never gets to test any code.

@robert-hoffmann
Copy link
Member

Nice hack man !

I can't diff it in right now cause i need to setup my dev environment again, but i'll definitely have a look and see if there are no hidden catches in there. Igorlima did some nice changes a while back https://github.com/headjs/headjs/pull/215/files but i think i rolled them back cause something was going wrong, and code seems very similar ..i'll just have to do all the unit tests ;-)

Minification/bundling is not automatic, i do it manually (well my dev environment does it..) before checking in the code. Gonna have to automate that with grunt ..maybe uglify.

@APlusDesign
Copy link

This definitely needs action, I mean I have to use crap like this to include a print a style sheet with head.js currently, I shiver every time I see it...

head.ready("jquery", function() {
    head.ready("print_css", function() {
        $('link[href="/pathtofile/print.min.css"]').attr('media','print');
    });
});

@jaypea
Copy link
Author

jaypea commented Sep 1, 2016

closing this after 2 years.

@jaypea jaypea closed this Sep 1, 2016
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

Successfully merging this pull request may close these issues.

3 participants