Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 6
Mario Campos

Where do I upload JavaScript files?

Question

17 answers to this question

Recommended Posts

  • 15

I contacted Squarespace Support and they provided a helpful answer, which I expanded open by organizing my scripts onto a single page:

  1. Add a new page called 'JavaScript Files' [optional]
  2. Go to Page Settings and Disable the page [optional]
  3. Add a Text Block
  4. Add some text, preferably the name of your JavaScript file, like Sample JavaScript
  5. Select the ‘Sample JavaScript’ text and make it into a Link
  6. Click Files on the Link menu
  7. Click in the white space and select the file from your hard drive (or drag it onto the space from your hard drive) - I’ll use javascriptfile.js for this example
    Upload an asset through a text link, yeah, not the most elegant way to do it, Squarepace!
  8. Click in the Text Block again, and click on the Link Text – Squarespace automatically displays the URL it points to when you click on it, which should be /s/javascriptfile.js [whatever the name of the file your uploaded is]
  9. You can right click and ‘Copy Link Address’ to make sure you have the correct URL
  10. Go to your Code Injection (either the Page’s Code Injection or your site-wide Page Injection) and insert the code:
    
    
    <script src="/s/javascriptfile.js"></script>

    Using the name of the file you just uploaded instead of javascriptfile.js of course.

You can keep adding JavaScript files, and it appears Squarespace automatically adds them to a javascriptfile.js directory.

No need to link scripts via Dropbox or include the entire script in the Code Injection.

You can use this to upload any file as well, but most other things have a place (CSS files and image get uploaded in the CSS Upload File area, etc.).

Source: Creating a Text Link

Edited by Mario Campos
Added Source from the relevant Squarespace help page

Marketing, Communications, IT, Business Dev. and Web Design

Share this post


Link to post
  • 1

@CedricLor Do any of your uploaded files have more than one '.' in the filename?

If so, there is a file renaming bug in Squarespace that strips out all but the last '.'

eg. myscriptname.min.js gets uploaded to /s/myscriptnamemin.js


Please hit LIKE to share your appreciation of posts that are helpful or useful. 

The like button is somewhere over thereover-there.jpg

Of course, Likes don't pay the bills.. If you're looking for a Squarespace Developer you can hire me here

Share this post


Link to post
  • 0

I don't disagree with you. Squarespace 6 is trying to streamline each file upload type to be more natural, but in the end you need a guidebook just to find out where to upload everything. Squarespace 5 was folder based which was not as 'cool' but definitely more usable.

I consider this method a hack until Squarespace 6 gets updated with a more useful file upload system. I think they can have various 'upload points' but it should all be easy. Folders work well, and we use them for a reason.


Marketing, Communications, IT, Business Dev. and Web Design

Share this post


Link to post
  • 0

Not sure why, even though this makes perfect sense it didn't work for me. Copy and paste the js file content into code injection area works perfectly.

Neither of these worked

Upon looking at the source in Firebug when I expanded my

There should be my script as far as I am concerned. Any ideas?

Edited by rsimko

Share this post


Link to post
  • 0

Hi Rsimko

Having the same issue as you, but more messie. Some of my files appear to have been uploaded and load on call. Other don't load, even they seem to have be uploaded. Very messy.

Mario Campos, did you ever manage to have Waypoint up and running on Squarespace? I am desperately fighting but can't seem to find a way out.

Thanks

Share this post


Link to post
  • 0

Hi @silvabokis, I noticed the bug, but this does not change anything.

Half of my uploaded files are loaded and the other half appears to have been uploaded on their servers but does not load with the pages.

From what I see, the files that are loaded are the no-framework Waypoints files while the JQuery Waypoints files do not load. They probably do not load because they cannot load the JQuery file, even this one is loaded...

So feed up with Squarespace...

Share this post


Link to post
  • 0

Anyone know if this will work on a product page in the product description? I need to inject JavaScript and be able to call that JavaScript from within a product description.

Thanks

Edited by thisisben

Share this post


Link to post
  • 0

@thisisben I see no reason why it shouldn't work.

However, be careful of the bug mentionned by @silvabokis and give squarespace some time (one night in my case as mentionned in my earlier post) for the files to be correctly uploaded and, more important, loaded.

Share this post


Link to post
  • 0

This works, I was having issues getting a muse parallax page with svg files working and for some reason uploading the styles and scripts via developer mode was not working so I tried this method and it actually works. So Happy.

Share this post


Link to post
  • 0

when i follow these steps, the file name is 's/fgojojouerpepw' (or something like that). However, when i try to reference it in my header by page-header-code-injection, like such, ', it doesn't find the file. What am I doing wrong?

Share this post


Link to post
  • 0

Just realized the sftp command line issue was I didn't include the site folder (as is mentioned in the page I referred to)

So, setup... I used a ssh config file since I couldn't quickly figure out how to provide a username with an ampersand in it to sftp command line program.

This example is good for GNU Linux, BSD etc will vary slightly for Windows.

# ~/.ssh/config

Host SQUARESPACE

HostName dev.squarespace.com

Port 2030

User your-user-name

And then at the command line just run the following sftp command

> sftp SQUARESPACE:/your-site-name

Edited by Philo

Share this post


Link to post
  • 0

Didn't see it mentioned here, see details about Developer Mode on http://developers.squarespace.com/initial-setup/. Don't know when it was first made available so it may be a recent addition.

In short, squarespace offers SFTP access to the template code for your site. It also provides a GIT repo of the template code, nice!

Note: I successfully used FileZilla to establish the SFTP connection, using sftp at command line would connect but was then immediately disconnected... didn't bother investigating further to figure out what was going on.

Share this post


Link to post
  • 0

Using this method, I am getting

Access to script at 'https://static1.squarespace.com/static/57014b5b746fb963478e3d4f/t/5d7ba83d4e25b616833d896b/1568385085375/runtime-es2015.js' (redirected from 'https://brooke-meek.squarespace.com/s/runtime-es2015.js') from origin 'https://brooke-meek.squarespace.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Do you know how to resolve this error? Thank you.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...