How to fix WebCenter Portal and jquery document ready function not running

Recently came across this issue on Webcenter Portal whenever you use jquery and the document ready function

$(document).ready{function(){alert('I am ready');}}

If this jquery is referenced as an <af:resource source=”jquery-test.js”/> in your page or page template, in certain use cases it will not execute the javascript . One of the instances is when the entire page is loaded via PPR is you navigate to another application and hit the back button. All the jquery javascript code within the ready function will not execute.

ADF renders the following to load javascript resources

<script type="text/javascript" language="javascript">AdfPage.PAGE.addResrouce('javascript', 'myjavascript.js');</script>

When its rendered in a ppr call this does not seem to execute the ready function. The way to fix this is to make sure you include the ready function in the jspx or page fragment.

The ideal way is to invoke this as a declarative component in your page or page template like so

<af:declarativeComponent id=”dc1″ viewId=”jquery.jsff”/>

Then make sure to add the page fragment jquery.jsff like so

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="" xmlns:f="" trh=""
          xmlns:af="" version="2.1">
    <af:componentDef var="attrs">
            <component xmlns="">
                <description>my jquery fragment</description>
        <!-- Actual content goes here-->
$(document).ready{function(){alert('I am ready');}}