Skip to content

Commit f130a64

Browse files
committed
lazy loading bsa
1 parent d980487 commit f130a64

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

app/assets/javascripts/bsa.js.coffee

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
jQuery ->
2+
if $('.bsarocks').length > 0
3+
console.log('Loading BSA')
4+
e = document.createElement('script')
5+
e.type = 'text/javascript'
6+
e.async = !0
7+
e.src = document.location.protocol + '//s3.buysellads.com/ac/bsa.js'
8+
(document.getElementsByTagName('head')[0] or document.getElementsByTagName('body')[0]).appendChild(e)
9+
10+
11+
$(document).on 'page:change', ->
12+
if window._bsap?
13+
console.log("Reloading BSA")
14+
_bsap.reload()

app/views/layouts/application.html.haml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,7 @@
1010
= csrf_meta_tags
1111
= render 'shared/analytics'
1212
= yield :head
13-
%body
14-
:javascript
15-
(function(){
16-
var bsa = document.createElement('script');
17-
bsa.type = 'text/javascript';
18-
bsa.async = true;
19-
bsa.src = '//s3.buysellads.com/ac/bsa.js';
20-
(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(bsa);
21-
})();
13+
%body
2214
.clearfix
2315
%header.border-bottom
2416
%nav.clearfix

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy