<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by BRCM on Medium]]></title>
        <description><![CDATA[Stories by BRCM on Medium]]></description>
        <link>https://medium.com/@it.brcm?source=rss-edbf63def73c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by BRCM on Medium</title>
            <link>https://medium.com/@it.brcm?source=rss-edbf63def73c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:26:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@it.brcm/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Speedup Web page load time without code changes]]></title>
            <link>https://medium.com/@it.brcm/speedup-web-page-load-time-without-code-changes-f9c25776b2a6?source=rss-edbf63def73c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9c25776b2a6</guid>
            <category><![CDATA[gzip-compression]]></category>
            <category><![CDATA[speed]]></category>
            <category><![CDATA[webpage]]></category>
            <category><![CDATA[web-page-performance]]></category>
            <category><![CDATA[h2]]></category>
            <dc:creator><![CDATA[BRCM]]></dc:creator>
            <pubDate>Sun, 07 Apr 2024 09:58:13 GMT</pubDate>
            <atom:updated>2024-04-07T09:58:13.060Z</atom:updated>
            <content:encoded><![CDATA[<p>There are many ways in which one can increase the page load time but most of them require code change and well thought out architecture and design pattern to be implemented from inception. Unfortunately that’s not what happens always, specially in case of small scale application with low budget.</p><p>Caching, minification and uglification, minimizing image size, use of CDN are few common ways to speedup the load time. I will focus on two simple ways to speedup up the load time of web pages:</p><p><strong>·</strong> Gzip compression</p><p><strong>·</strong> H2 protocol or HTTP/2</p><p>With heavy usage of JavaScript (JavaScript library and framework) its very important implement gzip and H2 protocol. Gzip will decrease the file size that will be transferred over network while H2 will help to speed up the delivery of same gzip files.</p><p>You can test your application for gzip and H2 using:</p><blockquote>Chrome developers tool network tab:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*npCOzuK0PwBFre2fpORymA.png" /></figure><blockquote>Online :</blockquote><p><a href="https://www.whatsmyip.org/http-compression-test/">Gzip</a></p><p><a href="https://gf.dev/http2-test">H2</a></p><p>Implementing gzip and H2 protocol in some of the widely used servers can be a matter of few minutes. Below are step for the same on Ubuntu and Windows.</p><blockquote><strong>Apache Http server:</strong></blockquote><p><em>Step 1: Install</em></p><pre>sudo apt install apache2</pre><p><em>Step 2: this step links to default page of http server, you will need to refer to your own application configuration</em></p><pre>sudo a2enmod rewrite</pre><p>edit : /etc/apache2/sites-enabled/000-default.conf, add below lines at the end</p><pre>&lt;Directory /var/www/html&gt;<br> AllowOverride All<br>&lt;/Directory&gt;</pre><p>restart apache</p><pre>sudo service apache2 restart</pre><p><em>Step 3: Gzip Compression</em></p><p>Use the .htaccess file, if not present then create one at &lt;Directory /var/www/html&gt; from step 2, with below content</p><pre># GZIP compression for files: HTML, CSS, JS, <br>&lt;IfModule mod_deflate.c&gt;<br> AddOutputFilterByType DEFLATE application/javascript<br> AddOutputFilterByType DEFLATE application/x-javascript<br> AddOutputFilterByType DEFLATE text/css<br> AddOutputFilterByType DEFLATE text/html<br> AddOutputFilterByType DEFLATE text/javascript<br>&lt;/IfModule&gt;</pre><p>you can add other file type :Text,XML, font -</p><pre># GZIP compression for files: Text, XML, Font</pre><pre>AddOutputFilterByType DEFLATE application/vnd.ms-fontobject<br>AddOutputFilterByType DEFLATE application/x-font<br>AddOutputFilterByType DEFLATE application/x-font-otf<br>AddOutputFilterByType DEFLATE application/x-font-ttf<br>AddOutputFilterByType DEFLATE application/xhtml+xml<br>AddOutputFilterByType DEFLATE application/xml<br>AddOutputFilterByType DEFLATE font/otf<br>AddOutputFilterByType DEFLATE font/ttf<br>AddOutputFilterByType DEFLATE text/plain<br>AddOutputFilterByType DEFLATE text/xml</pre><p><em>Step 4: H2 Protocol</em></p><p>Although H2 specification doesn’t need encryption but all major browser have decided to support HTTP/2 over TLS</p><p>Create SSL certificate : In production you should not use self signed certificates</p><pre>sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt</pre><p>Fill out the details asked after you ran above command.</p><p>Edit /etc/apache2/sites-available/default-ssl.conf</p><pre>&lt;IfModule mod_ssl.c&gt;<br>        &lt;VirtualHost _default_:443&gt;<br>              Protocols h2 http/1.1<br>              ServerAdmin your_email@example.com<br>              ServerName server_domain_or_IP<br>.<br>.<br>.<br>              SSLCertificateFile      /etc/ssl/certs/apache-selfsigned.crt<br>              SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key</pre><p>Enable H2 protocol</p><pre>sudo a2enmod ssl<br>sudo a2enmod http2</pre><pre>sudo service apache2 restart</pre><blockquote><strong>NGINX Server</strong></blockquote><p><em>Step 1: Install</em></p><pre>sudo apt-get install nginx</pre><p><em>Step 2: Gzip Compression is turned on by default, you can check the same in </em>/etc/nginx/nginx.conf</p><pre>##<br># Gzip Settings<br>##</pre><pre>gzip on;</pre><pre>gzip_vary on;<br>gzip_proxied any;<br>gzip_comp_level 6;<br>gzip_buffers 16 8k;<br>gzip_http_version 1.1;<br>gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;</pre><p><em>Step 3: H2 Protocol is configured in /</em>etc/nginx/sites-enabled/default</p><pre>listen 80 default_server;<br>listen [::]:80 default_server;</pre><pre>listen 443 ssl http2;<br>listen [::]:443 ssl http2;<br>ssl_certificate /etc/ssl/certs/apache-selfsigned.crt;<br>ssl_certificate_key /etc/ssl/private/apache-selfsigned.key;<br>ssl_protocols TLSv1.2;</pre><pre>root /var/www/html;</pre><pre># Add index.php to the list if you are using PHP<br>index index.html index.htm index.nginx-debian.html;</pre><pre>server_name _;</pre><p>Certificate used here are self signed and command to create is in above Http Apache server section.</p><p>Restart your nginx server.</p><blockquote>IIS server</blockquote><p>IIS server comes installed in windows 10 but it may not be turned by default</p><p>you can follow <a href="https://www.itnota.com/install-iis-windows/">the guide to turn on IIS feature</a> in windows</p><p>Gzip compresssion can be enabled use IIS manager : click compression and then enable dynamic content compression. <a href="https://docs.microsoft.com/en-us/iis/extensions/iis-compression/iis-compression-overview">For more details use Microsoft docs</a>.</p><p>H2 Protocol can be enable using the <a href="https://docs.microsoft.com/en-us/iis/get-started/whats-new-in-iis-10/http2-on-iis">Microsoft docs</a>.</p><p>Do keep in mind that H2 Protocol might not be available in older versions of servers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9c25776b2a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mirgration from RequierJS to Webpack with AngularJS!]]></title>
            <link>https://medium.com/@it.brcm/mirgration-from-requierjs-to-webpack-with-angularjs-347b4b5ec318?source=rss-edbf63def73c------2</link>
            <guid isPermaLink="false">https://medium.com/p/347b4b5ec318</guid>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[requirejs]]></category>
            <category><![CDATA[transpile]]></category>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[migration]]></category>
            <dc:creator><![CDATA[BRCM]]></dc:creator>
            <pubDate>Sun, 07 Apr 2024 09:54:42 GMT</pubDate>
            <atom:updated>2024-04-07T09:54:42.986Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="RequireJS AngularJS Webpack" src="https://cdn-images-1.medium.com/max/1024/1*TiTObpuOia-pQCooSmzoMw.png" /></figure><p>Webpack support AMD out of the box, which make migration from requirejs to webpack easy. Webpack will also help in modernization of your app by the use of appropriate plugin and then transpiling them back to any version for greater support, polyfilling your application, etc.</p><p>This is my journey of migration from RequireJS to Webpack and I will categorise the work under three labels, viz:</p><ul><li>Preparation</li><li>Webpack Migration</li><li>Handling HTML files, optional</li></ul><h3>Preparation</h3><p>This phase include making non-breaking changes to your angularJS/RequireJs project and this will help webpack in making its abstract syntax tree (AST) for processing files properly.</p><p><strong>Cleanup :</strong></p><p>If required, remove all the unused files, images and other assets (to decrease the build size)</p><p><strong>Use AngularJS in strict mode :</strong></p><p>This is required because when the files are minified angular throws injector error.</p><p>Turning to angularJS <a href="https://docs.angularjs.org/error/$injector/strictdi"><em>strict mode</em></a> basically means :</p><pre>app.factory(‘Foo’, function($http) { <br>// Angular will inject $http <br>});</pre><p>to either of below ways</p><pre>app.factory(‘Foo’, [‘$http’, function($http) { … }]);</pre><p>OR</p><pre>function Foo($http) {} <br>Foo.$inject = [‘$http’];</pre><p><strong>Use of relative path :</strong></p><p>In define() or require () use relative path for javascript instead of full path from your requireJS base path, if any.</p><p><strong>Use NPM and use AMD js files :</strong></p><p>If you are using bower migrating to npm will help migration to webpack. Webpack supports AMD file out of the box, so if you have any js file that is not written in AMD style convert the file into AMD style for starters any JS that is loaded from index.html</p><p><strong>Use import all CSS using less/sass files :</strong></p><p>Import all the css using sass or less file, optional if you want to build single css file instead on loading multiple css file which might be required by all the different third party dependencies you might be using.</p><h3>Webpack Migration</h3><p>Once you are done with preparation your code should work in requireJS. Now let’s migrate to webpack.</p><p><strong>Install webpack and other dependencies required :</strong></p><p>Below is list of dependency and dev dependencies that was required for my project and it can be a good start for anyone.</p><p>Dependency :</p><pre>&quot;dependencies&quot;: {<br>  &quot;@babel/polyfill&quot;: &quot;^7.7.0&quot;,<br>  .<br>  .<br>}</pre><p>Dev Dependency :</p><pre>&quot;devDependencies&quot;: {<br> &quot;@babel/core&quot;: &quot;^7.7.2&quot;, //transpiler<br> &quot;@babel/preset-env&quot;: &quot;^7.7.1&quot;,<br> &quot;babel-loader&quot;: &quot;^8.0.6&quot;,<br> &quot;babel-plugin-transform-remove-console&quot;: &quot;^6.9.4&quot;, //removes the    console.log<br> &quot;clean-webpack-plugin&quot;: &quot;^3.0.0&quot;, //clean the workspace for each new build<br> &quot;copy-webpack-plugin&quot;: &quot;^5.0.5&quot;,<br> &quot;css-loader&quot;: &quot;^3.2.0&quot;,<br> &quot;exports-loader&quot;: &quot;^0.7.0&quot;,<br> &quot;file-loader&quot;: &quot;^4.2.0&quot;,<br> &quot;html-webpack-exclude-assets-plugin&quot;: &quot;0.0.7&quot;,<br> &quot;html-webpack-plugin&quot;: &quot;^3.2.0&quot;,<br> &quot;imports-loader&quot;: &quot;^0.8.0&quot;,<br> &quot;less-loader&quot;: &quot;^5.0.0&quot;,<br> &quot;mini-css-extract-plugin&quot;: &quot;^0.8.0&quot;,<br> &quot;style-loader&quot;: &quot;^1.0.0&quot;,<br> &quot;webpack&quot;: &quot;^4.41.2&quot;,<br> &quot;webpack-cli&quot;: &quot;^3.3.10&quot;,<br> &quot;webpack-dev-server&quot;: &quot;^3.9.0&quot;<br>}</pre><p><strong>Create webpack file and define entry points :</strong></p><p>I’ve two entry points in my project one for css and one for js files.</p><pre>entry:{<br>&quot;main&quot;:[&quot;@babel/polyfill&quot;,&quot;./path/to/first/file/of/require.js&quot;],<br>&#39;style&#39;:  &#39;./path/to/lessORscss/file&#39;,<br>}</pre><p><strong>Create webpack alias files :</strong></p><p>Same as requireJS config file we need to define alias for the all the js</p><pre>const  path  =  require(&#39;path&#39;);<br>module.exports const  npmAlias  = {<br>&#39;angular&#39; : path.resolve(__dirname,&#39;node_modules/angular/angular.min&#39;),<br>.<br>.<br>.<br>}</pre><p>and add the reference to webpack config</p><pre>resolve:{<br> alias : npmAlias,<br>},</pre><p><strong>Define Output :</strong></p><p>Build path and filenames with hash</p><pre>output:{<br> filename:  &quot;[name].[contenthash].js&quot;,<br> path:path.resolve(__dirname,&#39;dist&#39;)<br>},</pre><p><strong>Define Plugin :</strong></p><p>Magical power to webpack comes from plugins. Identifying and using right plugin is subjective to once requirement.</p><p>Below are few of the plugin used by me for clean build path before each run, expose global variables, extract css, copy html,image, favicon,etc.</p><pre>plugins: [<br> new  CleanWebpackPlugin(), // clean build path<br> new  webpack.ProvidePlugin({<br>  &quot;_&quot; :  &#39;lodash&#39;,<br>  &quot;$&quot; :  &quot;jquery&quot;,<br>  &quot;jQuery&quot;:  &quot;jquery&quot;,<br>  &quot;jqLite&quot;:  &quot;jquery&quot;,<br>  &quot;window.$&quot; :  &quot;jquery&quot;,<br>  &quot;window.jQuery&quot;:  &quot;jquery&quot;,<br>  &quot;moment&quot;:  &quot;moment&quot;,<br>  &#39;Handlebars&#39;:&#39;handlebars&#39;,<br> }), // expose the global variable<br> new  MiniCssExtractPlugin({<br>  filename:&#39;[name].[contenthash].css&#39;<br>  }), // by  default js file is created for css, this will extract    the css out of it<br> new  HtmlWebpackPlugin({<br>  template:  &#39;./index.html&#39;,<br>  excludeAssets: [/(files/that/shouldn&#39;t be added in html )$/],<br>  filename:  &#39;index.html&#39;<br> }),<br> new  HtmlWebpackPlugin({<br>  template:  &#39;./error-file.html&#39;,<br>  excludeAssets: [/(files/that/shouldn&#39;t be added in html )$/],<br>  filename:  &#39;error-loading.html&#39;<br> }),<br> new  HtmlWebpackExcludeAssetsPlugin(),<br> new  CopyPlugin([<br>  {from:  &#39;app/**/*&#39;,ignore: [&#39;*.js&#39;]}, //copy all the html files to   build path<br>  {from:  &#39;assets/favicon&#39;, to:&#39;assets/favicon&#39;},// copies favicon<br>  {from:  &#39;assets/img&#39;, to:  &#39;assets/img&#39;},//copies images<br>]),<br>],</pre><p><strong>Define rules for webpack :</strong></p><p>File like images, fonts are process with specific loaders Also rules is used to set the transpiler options, shiming, etc.</p><p><em>Transpil to ES5 and remove console.log using babel</em></p><pre>rules:[<br>{<br> test: /(\.js)$/,<br> exclude: /(node_modules|bower_components)/,<br> use: {<br>  loader:  &#39;babel-loader&#39;,<br>  options: {<br>    presets: [&quot;@babel/preset-env&quot;],<br>    plugins: [[&quot;transform-remove-console&quot;, { &quot;exclude&quot;: [ &quot;error&quot;, &quot;warn&quot;] }] ]<br>   }<br> }<br>},//tranpiler to ES5 and remove console.log using babel</pre><p><em>Exporting angular object</em></p><pre>{<br>test: /angular\.min/,<br>use:[{loader:&#39;exports-loader?angular,window.angular&#39;},   {loader:&#39;imports-loader?moment,this=&gt;window&#39;}]<br>}, //rule for exporting angular object.</pre><p><em>Handle less, image, fonts, files</em></p><pre>{<br>test : /\.less$/,<br>use:[<br>MiniCssExtractPlugin.loader,<br>{loader:&#39;css-loader&#39;},<br>{loader:&#39;less-loader&#39;}<br>]<br>},//rule for less files<br>{<br>test: /\.(woff|woff2|eot|otf|ttf)(?:\?.*|)$/,<br>use:[{loader:  &#39;file-loader&#39;,<br>options: {<br>name:  &#39;[name].[ext]&#39;,<br>outputPath:  &#39;assets/fonts&#39;,<br>publicPath:  &#39;assets/fonts&#39;<br>}}<br>]<br>},// rule for coping the fonts<br>{<br>test: /\.(png|svg|png|jpg|gif)(?:\?.*|)$/,<br>use:[{loader:  &#39;file-loader&#39;,<br>options: {<br>name:  &#39;[name].[ext]&#39;,<br>outputPath:  &#39;assets/img&#39;,<br>publicPath:  &#39;assets/img&#39;<br>}}<br>]<br>}//rule for coping the images</pre><p><strong>Optimize :</strong></p><p>One of the ways to optimize is by breaking the code into chunks as of now all the js code will pushed into one file, which will be huge.</p><p>Below optimization breaks the code into your code vs npm modules</p><pre>optimization: {</pre><pre>splitChunks: {<br> cacheGroups: {<br>  vendor: {<br>   test: /node_modules/,<br>   name:  &quot;vendor&quot;,<br>   chunks:  &quot;initial&quot;,<br>   enforce:  true<br>  },<br>...// add more module to be broken into chunks</pre><h3>Handling HTML files, optional</h3><p>Uptil this point the changes were non-breaking meaning both webpack and requireJS will be working fine. This is an optional step but will cause breaking changes.</p><p>Compiling HTML with webpack is definitely recommended.</p><p>Alternatively, you can copy the HTML file to build path(as, explained above)</p><p>Below is the code change required, so that webpack can scan these html and you will might need to change the rules of copy HTML as done above.</p><pre>angular.module(&#39;app&#39;)<br>.component(&#39;your.component&#39;, {<br>template: require(&#39;./relative/path/to/yourComponent.html&#39;),</pre><h3>Conclusion</h3><p>There are lots of option at your disposal when you use webpack, this is very basic use of webpack to build an existing RequireJs project, like webpack-dev-server to for live reloading and compiling.</p><p>You should explore plugins,loader as per you project need and I hope this article helps you with your journey.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=347b4b5ec318" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>