DEV Community

Melvin Jones Repol
Melvin Jones Repol

Posted on

Keep url clean

We liked to use url params such as utm source, ref and custom one. But leaving it like that makes the url lenght quite long for example Searching on google then clicking on a particular content google will highlight it for you to see it easily but it append a data in the url like:

http://mrepol742.github.io/webvium#:~:text=webvium

Webvium

Also utm like http://mrepol742.github.io/?utm_source=dev.to&utm_medium=blog

And personally it wasnt look cool.

It's possible to remove the url parameters by using replaceState from window.historu as follows:

what it does is to replace the current url using the window.location.pathname leaving with clean and easy to read url.

Top comments (2)

Collapse
 
moopet profile image
Ben Sinclair

Browsers are starting to remove spam and tracking links these days anyway, so hopefully those days will be over soon.

Collapse
 
mrepol742 profile image
Melvin Jones Repol

yes bro and btw thats a good idea.. im working on my personal project browser for android i would say removing known tracker like utm is such a great idea.. i will look into it.. as of this moment what ive achieved in blocking tracking is by identifying the resources url if it links or says that is related to analytics tracking etc... i also do the same thing on ads but if they hosted the tracking on there own i dont know then probably allow users to add custom domain to be block.