Skip to content

data-URI scripts insertion #1887

@rhyzx

Description

@rhyzx
var s = document.createElement('script')
s.src = 'data:,console.log(1)'

document.body.appendChild(s)
// output 1

but if insert this script by jQuery: $('body').append(s), it will be get an error.


this is due to jQuery execute script by ajax of script[src],
and jQuery will append extra query params _=xxxx to prevent script cache by default.
https://github.com/jquery/jquery/blob/2.1.1/src/manipulation/_evalUrl.js#L9

fix this is simple, just set cache=true… may i pull a PR for this?


by the way, anyone knows why jQuery set async=false for inserted scripts?
this is inconsistent with browser's default behavior

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions