Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dCuxP-0004T1-NF for pgadmin-hackers@arkaria.postgresql.org; Mon, 22 May 2017 21:33:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dCuxP-0006Xi-22 for pgadmin-hackers@arkaria.postgresql.org; Mon, 22 May 2017 21:33:39 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dCux9-00066Q-I4 for pgadmin-hackers@postgresql.org; Mon, 22 May 2017 21:33:23 +0000 Received: from mail-it0-x235.google.com ([2607:f8b0:4001:c0b::235]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dCux1-0003ct-RI for pgadmin-hackers@postgresql.org; Mon, 22 May 2017 21:33:22 +0000 Received: by mail-it0-x235.google.com with SMTP id g126so6348919ith.0 for ; Mon, 22 May 2017 14:33:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgadmin-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=NmQh/GzOcNDEMbYQDGtVZiBTo+mzqLnx3aZKaYZguvk=; b=m+yKjsEdlMgK4y3Xp7EWnF8GIGyk7mMC3sv0seVCUm8r+AVLOU5LZnMpvCEgs8Nask 1zRs0g0Gmuwu1wDKpvGssg20qcJ2XyEEhkMFMYU1QQRoY2bE9LAXgVl7HsKxhuLt47g6 /PpBTgRHFSehFLr47G2A5tbXGoGWCwLpOoEj564m8T42TFucu91/44RhDLyOiUgi9wPI jnr4FMWZFgdgO/wEdtxfo601DDZHaNYpafDgzYgdQrhii3szq+DFyDUbF8GnrgfXtiSM nMew64pWsJFhm6YXgEAPBmG1259X/gIe9nP7RbU7lmvImewbiMV2mXbrFmFBq9CK0euF Almg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=NmQh/GzOcNDEMbYQDGtVZiBTo+mzqLnx3aZKaYZguvk=; b=BPs52rcuTuoIxPZzIIPjpYV3u8wu3LoC87qwxFNctLm5g2i401nSYkKuYHtpuPJqIT e871s7LHgcBU5ZQWyimpdODipcbP0FP6dEsmDU+Z9R/jPIyxCqi8HcQt/DjL1ObdZ5j+ 0i3KUEu4yDlfe1ADIEH619SZ9F4vMTDbEjjbZ6k0Yn8fWT2WRlzJoxCeDYahXR4haKgR M8Io9tQS0hZSmDtYcSWVNn8lv1DTsrhBkk7L2CNXx9gO1m1dqi8RK76/XUb1xEP2Lac6 5oFduInSP0ie+GpQEfM78QW//b/u112IVOK6codmR0hapOdnIv5B9YfZ6QrlZhyIVTg1 ARNw== X-Gm-Message-State: AODbwcBCokgou9wDBMvem8cO8JzcrGIF5iE+7+5y7+DJWZFAvl1qIz0I fxvBSu9dEFU2mzKGD/PG9PEw8g880iA886I= X-Received: by 10.36.31.74 with SMTP id d71mr23678743itd.85.1495488794634; Mon, 22 May 2017 14:33:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.174.147 with HTTP; Mon, 22 May 2017 14:33:13 -0700 (PDT) In-Reply-To: References: From: Dave Page Date: Mon, 22 May 2017 22:33:13 +0100 Message-ID: Subject: Re: [pgAdmin4][Patch]: Load module's JS files only when required To: Surinder Kumar Cc: pgadmin-hackers Content-Type: multipart/alternative; boundary="001a1145ecc65efc7f0550239e04" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgadmin-hackers Precedence: bulk Sender: pgadmin-hackers-owner@postgresql.org --001a1145ecc65efc7f0550239e04 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi On Monday, May 22, 2017, Surinder Kumar wrote: > Hi > > On Mon, May 22, 2017 at 4:22 PM, Dave Page > wrote: > >> Hi >> >> On Monday, May 22, 2017, Surinder Kumar >> wrote: >> >>> Hi >>> >>> As per pgAdmin4 design, template JS files can either be preloaded or >>> load when a specific node expands (by adding for e.g.: when: 'server'). >>> >>> The JS files of several modules found to be loaded when pgAdmin4 loads >>> which results in increasing: >>> >>> - the number of http requests >>> - latency(greater request time) >>> - pgAdmin4 load time >>> >>> *Tested on Firefox:* >>> >>> Before applying patch >>> >>> - http requests - 143 >>> - Content size - 3.4 MB >>> - Load time: 4.1s (onload: 524ms) >>> >>> After applying patch >>> >>> - http requests: 68 >>> - Content size: 2.1 MB >>> - Load time: 2.84s (onload: 481ms) >>> >>> This is great work! >> >> However (sorry!) - I'm planning on working on an alternative change on m= y >> flight in a couple of hours. Joao has broken the Grunt code out of the >> History tab patch for me to work with - the idea is something like: >> >> - We continue to migrate all the JS out of templates and into static >> files whereever possible, using the client-side translation. >> > =E2=80=8BYes. It will be then easier to cover most of the JS code for min= ify if > client side =E2=80=8Btranslation is used. > Unfortunately, I looked at this on my flight and it looks like it'll be a mammoth task. Many/most JS files also currently use the url_for template function - so we need to figure out how to replace that with JS code first. > >> - We then have a set of Grunt tasks that will collect all the static JS, >> minimise it, and pack it into a single file to load at startup. >> > =E2=80=8BI wrote few grunt tasks using r.js optimizer this weekend which: > > 1. Finds all static JS file recursively into the modules using regex > pattern and then creates the tasks to minify each JS file and store its > 'min.js' in same directory and loads min.js when current_app.debug is Fal= se > else returns JS file. > > 2. A task to merge given list of CSS files into a single file and then > minify using 'grunt-contrib-cssmin' task and then insert that file with >