[Pro] Protaculous 2 problem

I’ve upgraded to Freeway Pro 6 and installed Protaculous 2 to replace Protaculous. The site contains some custom actions that should appear before the end of the head tag. Unfortunately the prototype and scriptaculous script references are appearing after the javascript generated by the custom actions and the document.observe function is throwing an error. Is there a way to force the references to the prototype and scriptaculous script references to appear immediately after the head tag?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Make sure that you add any scripts that you want to use with Prototype in one of the Observer editors, not using the Page / HTML Markup. These fields already write the document.observe and Event.observe, and then there’s also the third Custom observer where you can write anything you want. All of them will place their code after the Prototype and Scriptaculous libraries.

I was going to suggest removing your custom Action and adding Protaculous first, then adding it back, but I just checked, and that’s probably not going to work, because Protaculous 2 only uses the fwBeforeEndHTML callback, which is really late. Can you adjust the custom Action to place its code in the After section? Protaculous always puts its libraries in the head.

One last thing you can try is to apply Protaculous to the page, then apply Protaculous 2 on top of that. What that will do is write the Prototype and Scriptaculous very first in the page (because that was how the old system worked) and then Protaculous 2 will “upgrade” the versions of the libraries, but it won’t move them from their spot in the page, so they will be where you need them to be. You will end up with copies of the old libraries in your Resources folder, but they won’t be linked so they won’t download and they won’t contribute to page size. (Freeway will lie and tell you that you’ve added 600KB of JavaScript to your page or something awful like that – don’t listen!)

Walter

On Oct 24, 2013, at 9:10 PM, Christopher Benz wrote:

I’ve upgraded to Freeway Pro 6 and installed Protaculous 2 to replace Protaculous. The site contains some custom actions that should appear before the end of the head tag. Unfortunately the prototype and scriptaculous script references are appearing after the javascript generated by the custom actions and the document.observe function is throwing an error. Is there a way to force the references to the prototype and scriptaculous script references to appear immediately after the head tag?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Give this a try:

You’ll have to download it and save it as Protaculous2.fwaction and replace the copy in your Actions Folder. All I did was duplicate the library link code and put it into the fwAfterStartHead callback. What this means is that this version will be unable to update FX Actions and Protaculous – that was why the Protaculous 2 put it later in the publish cycle. So use this in isolation, not the way the original Action was written.

Walter

On Oct 24, 2013, at 9:10 PM, Christopher Benz wrote:

I’ve upgraded to Freeway Pro 6 and installed Protaculous 2 to replace Protaculous. The site contains some custom actions that should appear before the end of the head tag. Unfortunately the prototype and scriptaculous script references are appearing after the javascript generated by the custom actions and the document.observe function is throwing an error. Is there a way to force the references to the prototype and scriptaculous script references to appear immediately after the head tag?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks Walter,

It was so helpful to be given a number of options to try.

I moved the javascript for my custom action to after the start of the body and everything now seems to be working fine.

Cheers,
Chris


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Glad to help. This is an interesting problem, and it exposes a weakness of the approach I took. I was most concerned when I wrote this that I have a route to fix any lingering “legacy” Prototypes, because having more than one is very bad, and having an old one is “kinda” bad. Those seemed like the worst thing, and what I should attack front-on.

You really might want to look again at your code and see if you can move your custom code into the DOM Loaded or Window Load observers in the Protaculous 2 Action. That’s where they belong, and it makes everything so much neater. For one thing, if you enable external scripts, you will end up with a much cleaner section, as everything is shifted outside the page. If you use the same script on more than one page, that means the browser can cache it and you will get a boost there as well.

Walter

On Oct 25, 2013, at 1:07 AM, Christopher Benz wrote:

Thanks Walter,

It was so helpful to be given a number of options to try.

I moved the javascript for my custom action to after the start of the body and everything now seems to be working fine.

Cheers,
Chris


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options