Skip to content

Commit c7b2fcd

Browse files
committed
Check for script earlier.
Also drop the hard tabs
1 parent 7e07987 commit c7b2fcd

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

jquery.pjax.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,17 +246,18 @@ function pjax(options) {
246246
if (container.title) document.title = container.title
247247
context.html(container.contents)
248248

249-
container.scripts.each(function(_, script) {
250-
var $script = $(script)
251-
var src = $script.attr('src')
252-
var target = document.head || context.get(0)
253-
var tag = document.createElement('script')
254-
tag.type = $script.attr('type') || "text/javascript"
255-
tag.async = false
256-
tag.src = src
257-
if(!$('script[src="' + src + '"]').length)
258-
target.appendChild(tag)
259-
})
249+
container.scripts.each(function(_, script) {
250+
var $script = $(script)
251+
var src = $script.attr('src')
252+
if($('script[src="' + src + '"]').length) return
253+
254+
var target = document.head || context.get(0)
255+
var tag = document.createElement('script')
256+
tag.type = $script.attr('type') || "text/javascript"
257+
tag.async = false
258+
tag.src = src
259+
target.appendChild(tag)
260+
})
260261

261262
// Scroll to top by default
262263
if (typeof options.scrollTo === 'number')

0 commit comments

Comments
 (0)