uPortal IRC Logs-2013-06-19
[12:25:23 CDT(-0500)] <obbo> hello, i am seeing an issue with webproxy portlet. i have a small page that is displayed in the portlet and the page has a couple screens that you can navigate through via ajax. that is working fine and the links all work but after a while of navigating between each screen, the portlet begins to slow down and it takes longer and longer to navigate between screens
[12:26:17 CDT(-0500)] <EricDalquist> unless the ajax is written in a very specific way it will not work with the proxy portlet
[12:26:31 CDT(-0500)] <EricDalquist> as the portlet has no way to intercept the ajax calls and route them through the portlet
[12:26:59 CDT(-0500)] <obbo> i'm pretty sure it is being written correctly as i am able to use it through the portlet
[12:27:02 CDT(-0500)] <EricDalquist> http://jasig.275507.n4.nabble.com/data-ajax-returns-does-not-display-data-within-webproxy-portlet-td4355777.html
[12:27:28 CDT(-0500)] <EricDalquist> as for the slowness
[12:27:28 CDT(-0500)] <EricDalquist> O
[12:27:37 CDT(-0500)] <obbo> just that the first few interactions with the portlet work fine but after that it starts to slow down
[12:27:38 CDT(-0500)] <EricDalquist> I'm not sure what would be the cause without more info
[12:27:47 CDT(-0500)] <EricDalquist> can you tell which step is getting slow?
[12:27:54 CDT(-0500)] <EricDalquist> like is it the client side js
[12:28:07 CDT(-0500)] <EricDalquist> or the actual ajax request handling?
[12:28:47 CDT(-0500)] <obbo> are you able to view the ajax requests handled by the portlet with chrome's dev tools?
[12:29:11 CDT(-0500)] <EricDalquist> yeah, browser side they don't change at all
[12:29:55 CDT(-0500)] <obbo> ah, yes i see them now
[12:30:42 CDT(-0500)] <obbo> ha, i see my problem. on each ajax request it is loading my template which requests jquery so after clicking 20 times i get 20 jquery requests
[12:30:56 CDT(-0500)] <obbo> 20 requests for the jquery library
[12:31:03 CDT(-0500)] <EricDalquist> hah
[12:31:06 CDT(-0500)] <EricDalquist> yeah that would do it
[12:40:32 CDT(-0500)] <obbo> EricDalquist: so in my case the template was including jquery via google's cdn. would it work in web proxy if i included it off the filesystem instead? so it doesn't get included every time?
[12:41:21 CDT(-0500)] <EricDalquist> well every time the script is loaded on the page the browser will load it
[12:41:51 CDT(-0500)] <EricDalquist> so you need to load the jquery script once when the page loads initially
[12:41:59 CDT(-0500)] <EricDalquist> and then just use that same instance for the rest of the life of the page
[12:42:32 CDT(-0500)] <obbo> if i don't include it, is it possible for the proxied portlet to use uportal's jquery instead?
[12:42:37 CDT(-0500)] <EricDalquist> it is
[12:42:41 CDT(-0500)] <EricDalquist> but you can't be sure of the version
[12:42:55 CDT(-0500)] <EricDalquist> we don't worry about portlet compatibility for uportal's javascript
[12:43:09 CDT(-0500)] <obbo> ok, thanks. understandable
[12:43:11 CDT(-0500)] <EricDalquist> why do you need to reload the <script> tag every time?
[12:44:46 CDT(-0500)] <obbo> the portlet is proxying a webpage we already had written. the page used jquery and we just pointed web proxy portlet at it
[12:44:56 CDT(-0500)] <EricDalquist> ok
[12:45:04 CDT(-0500)] <EricDalquist> so when you interact with that page
[12:45:08 CDT(-0500)] <EricDalquist> does it reload the whole portal page
[12:45:13 CDT(-0500)] <EricDalquist> or just the content in the wpp portlet?
[12:45:24 CDT(-0500)] <obbo> just the content in wpp
[12:47:07 CDT(-0500)] <EricDalquist> ah
[12:47:18 CDT(-0500)] <EricDalquist> yeah that would be a problem then
[12:47:39 CDT(-0500)] <EricDalquist> you would need to unbind all of the stuff that the WPP content jquery
[12:47:41 CDT(-0500)] <EricDalquist> is doing
[12:47:44 CDT(-0500)] <EricDalquist> otherwise it will leak memory
[12:49:55 CDT(-0500)] <obbo> is there anything special i need to do to have the wpp content use uportal's jquery? i removed the request for google's jquery but now it just tells me $ is undefined, like it doesn't see uportal's jquery
[12:50:43 CDT(-0500)] <EricDalquist> so uPortal and all portlet's use jQuery in noconflict mode
[12:50:59 CDT(-0500)] <EricDalquist> https://wiki.jasig.org/display/PLT/JavaScript+Best+Practices
[12:51:08 CDT(-0500)] <EricDalquist> uPortal's jQuery instance lives at "up.jQuery"
[12:51:38 CDT(-0500)] <EricDalquist> what you should do is wrap javascript that needs a reference to jQuery with:
[12:51:42 CDT(-0500)] <EricDalquist> (function($) {
[12:51:46 CDT(-0500)] <EricDalquist> JSHERE
[12:51:54 CDT(-0500)] <EricDalquist> })(up.jQuery);
[12:52:03 CDT(-0500)] <EricDalquist> that makes the $ var available but only in the closure
[12:52:06 CDT(-0500)] <EricDalquist> instead of globally
[12:52:10 CDT(-0500)] <obbo> ah, ok. thanks
[12:52:10 CDT(-0500)] <EricDalquist> which could break other things on the page
[12:52:24 CDT(-0500)] <EricDalquist> note that WPP has the ability to do pre/post static htmlk
[12:52:27 CDT(-0500)] <EricDalquist> so you could add that
[12:52:38 CDT(-0500)] <EricDalquist> and pull in a specific version of jquery there
[12:52:50 CDT(-0500)] <EricDalquist> grab it into a no-conflict reference
[12:53:30 CDT(-0500)] <EricDalquist> then in the post html you could do that closure to make the $ available
[12:54:58 CDT(-0500)] <obbo> yeah, that sounds like a better idea. the js uses 1.7+ apis a lot. i'll look into that. thanks for all your help
[12:55:09 CDT(-0500)] <EricDalquist> yup
[12:55:14 CDT(-0500)] <EricDalquist> good luck