Codeexecute | Page 3 of 31 | Online Forum To Support Coders With Technical Assistance

Single Page Application vs Multi Page Application (SPA vs MPA)

In the era of cloud , every application has been / being migrated from desktop to web server. And companies  earlier having their older softwares on systems are creating the same  as web app for easy and global approach of clients. Now the webapp could be categorized into two types – One is traditional Multi Page Application and the other one is the latest and new approach as Single Page Application.What are SPA or MPA? Let’s figure out.

SPA (Single Page Application):

The latset approach towards creating the web app is Single Page application where all of the content from the server is rendered on single page html. It means:

  1. The routing is maintained on client side through Java Script
  2. Devlopement is easy and no need to learn different templating language for a front end devloper to develop the web pages like PHP, JSP or django templating
  3. Required data on page is served through JSON API from server not using context variables
  4. Switching into multiple URLs in the web page is easier and faster since routing is on clinet side
  5. Since all static content like CSS/JS has been loaded initially so redundancy of static variables minimizes the server load
  6. Using the same API the mobile application can be simultaneously build reducing the load of back end devloper.In this way a back end devloper can concentrate over business logic and code optimzation instead working on page rendering stuff of fron end.
  7. The devlopement would be fast as the front end and mobile developer can build their application using dummy api’s and later integrating them.

Example of SPAs : gmail, Facebook, Twitter

Multi Page Application(MPA)

The web app consists of multiple pages and all of these are rendered on server side.

  1. Rourting is maintained on server side
  2. Web app speed is slow as each routing requires a call towards server whihc may take additional round trip towrads server.
  3. SEO is better managed in MPA
  4. Backend devloper need to create mobile APIs to give JSON data to mobile devlopers(redundancy of logic).
  5. Tightly coupled front end /backend

As per the given approach it seems to be use SPA for a better user experience and fast devlopment process.

However the SPA also having their own cons. At the end the approch completely depends upon what is the business need.

So take a call and analyze which should be best for you..


Strip HTML Tags using Javascript

So folks, sometimes it happens that you are saving some text with formatted data like HTML string but while displaying you don’t want to display it not as string but as formatted text.i.e. want to strip  HTML tags from the content here is the slution for it:


function stripTags(html) {
var tmp = document.createElement("DIV");
tmp.innerHTML = html;
return tmp.textContent || tmp.innerText || "";


Javascript Hoisting

Javascript Hoisting :

Javascript a weekply typed language, and if we are not using the ‘strict’ mode in JS, there are so many code practices which can be avoided with Javascript unlike any other languages.

One of these practise is that we can use a variable before declaring it.Yes, you heard it right;

In JavaScript, a variable can be declared after it has been used.

In other words; a variable can be used before it has been declared.


So below syntax of a program is correct;

x = 5;

console.log('x is', x); // 'x is 5'

var x ;

As we saw in previous example, there is no error thrown for the above syntax, however the variable is declared after the initialization. Here comes the most unpredicted behavior of Javascript, i.e. hoisting.

What does the hoisting means?

According to MDN, hoisting means all the declarations, irrespective of their positions are moved to the top of the function scope or the global scope .i.e actualy the behaviour in all the strongly typed langauges where the variable declarations are done in the starting of their scope, Here the difference in Javascript is that, this work is done by Javascript engine for us in Javascript. Got confused ?? So let’s have an example.

Go to your console and type

console.log( a); //ReferenceError: a is not defined

So you got a reference error, a is not defined, which seems to be correct. Since there is no variable a in your scope you got an error.

Now take Example 2 :

console.log(b) //undefined
var b;

Now  you can see , there is no reference error. Since variable has been declared and JS engine has moved it to top. So varibale has been declared but not given any value and by default if variable is not initiated in JS then it would be assigned undefined, hence the output s undefined.  According to JS the above code would be compiled as

var b;


so what does we said , the variable decalarion has been moved to top, irrespective of it’s position.

Now guess the output of example 3.

Example 3

console.log(c); //undefined
var c = 3;

You can see the output is undefined again, because the variable declartion is only moved to top not the variable assignment. and by defualt the variable would be assigned with an undefined value.

Example 3 would be interpretted as in JS engine

var c;


c = 3;

So you got the concept of the hoisting , please give your answer for the follwoing code before scroll.

console.log('First d is:' d);

var d = 9;

console.log('Second d is : ', d);

//First d is : undefined.
//Second d is : 9.


What is seo

SEO - Search Engine Optimization
SEO (Search engine optimization) is the process or a technique of getting traffic from search results on search engines.
According to Wikipedia seo is the process of affecting the online visibility of a website.


Types of Seo :

  1. White Hat Seo
  2. Black Hat Seo

Basic Techniques :

  1. Unique content
  2. Use seo friendly url’s
  3. Use proper page titles
  4. Use proper meta title & description
  5. Use header tags(h1-h6) on your web page
  6. Internal linking
  7. Add alt  tag to website’s images
  8. Create a sitemap
  9. Update site regularly
  10. And keep some patient

Advantages :

  1. Site traffic increased
  2. Increase leads
  3. Brand credibility
  4. Increase value of your website/business
  5. Improve earning