{"id":345,"date":"2016-05-15T13:18:41","date_gmt":"2016-05-15T13:18:41","guid":{"rendered":"http:\/\/www.baltas.biz\/en\/?p=345"},"modified":"2016-05-15T13:18:41","modified_gmt":"2016-05-15T13:18:41","slug":"making-code-cleaner","status":"publish","type":"post","link":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/","title":{"rendered":"Making your code cleaner"},"content":{"rendered":"<p class=\"p1\"><span class=\"s1\">I guess that every new programer did double coding one or other time in his career.<\/span><\/p>\n<p class=\"p1\"><span class=\"s1\">By double coding i mean, wrote the same code for two different elements.<\/span><\/p>\n<p class=\"p1\"><span class=\"s1\">CSS example:<\/span><\/p>\n<p class=\"p2\">\u00a0<code>.class1 {<\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0 \u00a0margin: 50px auto;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0 \u00a0background-color: white;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0 \u00a0width: 300px;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0 \u00a0text-align: center;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0 \u00a0border: solid 1 px red;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0 \u00a0padding: 15px;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">}<\/span><\/code><\/p>\n<p class=\"p2\">\n<p class=\"p1\"><code><span class=\"s1\">.class2 {<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0 \u00a0margin: 50px auto;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0 \u00a0background-color: white;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0 \u00a0width: 300px;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0 \u00a0text-align: center;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0\u00a0 border-color: red;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0 \u00a0border-width: 1px;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0\u00a0 border-style: solid;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">\u00a0 \u00a0padding: 15px;<\/span><\/code><\/p>\n<p class=\"p1\"><code><span class=\"s1\">}<\/span><\/code><\/p>\n<p class=\"p1\"><span class=\"s1\">Most likely this will not happen one after another, but if you have along style sheet it might happen since you forget to you wrote something similar, or you are trying to style a completely different template and haven to have an element that has to look like one in a previous template so you should obviously use the class you defined before. Best option i can give you before styling templates look over the design think what parts are similar. Then at the middle and end of your project look over your styles try to look for code you don&#8217;t need, trim it.<\/span><\/p>\n<p class=\"p1\">\u00a0Another thing is when you have some elements in the web page that after a time you decided are not necessary any more and deleted them don&#8217;t forget to remove the styles for the element as well.<\/p>\n<p class=\"p1\"><span class=\"s1\">Another thing is its not only about the styling it self. If you have an element with a border all around it i don&#8217;t recommend using \u201cborder-style: solid; border-width: 1px; border-color: red;\u201d you would save up 2 lines of code just by using one command \u201c border: solid 1px red\u201d. Same goes for margin if you have at least 2 margins for an element like \u201c margin-left: 5px; margin-top: 10px;\u201d I could surest using \u201cmargin: 10px 0 0 5px\u201d. The tricky thing for one line margin is that if you want margin only for one side you have to set the other side 0. it goes like this \u201cmargin 5px; = margin-top: 5px;,\u00a0<\/span>margin-right: 5px;, margin-bottom: 5px;, margin-left: 5px;\u201d. The one line margin respectively goes like this \u201cmargin: first number top, second number right, third number bottom, last number left\u201d. And so you would understand how it helps look over how many of your elements use margin ten and how much lines can you trim if you use one line margins. This also applies to background, border-radius and few other things.<\/p>\n<p class=\"p1\">I may have gave you a CSS example but this actually helps with Javascript and PHP.<\/p>\n<p class=\"p1\"><span class=\"s1\">For example in JavaScript you use functions. There are times when you use quite a few of them depending on the websites functionality. Look for things that do the same functionality put them in one function invoke them with different parameters. Same goes for PHP.<\/span><\/p>\n<p class=\"p2\">What I&#8217;m getting at is that you need to analyse your own code. Don&#8217;t go thinking that if every thing works that its ok to have everything jumbled 5 pages of styles and so on. Just think about the time when you might need to fix something or add something one 6 months time when you have basically forgotten whats where.<\/p>\n<p class=\"p2\">P.S. Something\u00a0i found that explains how to help yourself &#8211;\u00a0<a href=\"http:\/\/www.labnol.org\/internet\/remove-unused-css\/28635\/\" target=\"_blank\">labnol.org post on how to &#8211; Remove Unused CSS<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I guess that every new programer did double coding one or other time in his career. By double coding i mean, wrote the same code for two different elements. CSS example: \u00a0.class1 { \u00a0 \u00a0margin: 50px auto; \u00a0 \u00a0background-color: white; \u00a0 \u00a0width: 300px; \u00a0 \u00a0text-align: center; \u00a0 \u00a0border: solid 1 px red; \u00a0 \u00a0padding: 15px; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":346,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-345","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Making your code cleaner - Baltas<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Making your code cleaner - Baltas\" \/>\n<meta property=\"og:description\" content=\"I guess that every new programer did double coding one or other time in his career. By double coding i mean, wrote the same code for two different elements. CSS example: \u00a0.class1 { \u00a0 \u00a0margin: 50px auto; \u00a0 \u00a0background-color: white; \u00a0 \u00a0width: 300px; \u00a0 \u00a0text-align: center; \u00a0 \u00a0border: solid 1 px red; \u00a0 \u00a0padding: 15px; [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/\" \/>\n<meta property=\"og:site_name\" content=\"Baltas\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-15T13:18:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.baltas.biz\/wp-content\/uploads\/2016\/05\/314_20155153YVSWJE.png\" \/>\n\t<meta property=\"og:image:width\" content=\"700\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"baltas\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"baltas\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/en\\\/making-code-cleaner\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/en\\\/making-code-cleaner\\\/\"},\"author\":{\"name\":\"baltas\",\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/#\\\/schema\\\/person\\\/42fb2887449ead82c3023240e547d0ac\"},\"headline\":\"Making your code cleaner\",\"datePublished\":\"2016-05-15T13:18:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/en\\\/making-code-cleaner\\\/\"},\"wordCount\":496,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/en\\\/making-code-cleaner\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.baltas.biz\\\/wp-content\\\/uploads\\\/2016\\\/05\\\/314_20155153YVSWJE.png\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/en\\\/making-code-cleaner\\\/\",\"url\":\"https:\\\/\\\/www.baltas.biz\\\/en\\\/making-code-cleaner\\\/\",\"name\":\"Making your code cleaner - Baltas\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/en\\\/making-code-cleaner\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/en\\\/making-code-cleaner\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.baltas.biz\\\/wp-content\\\/uploads\\\/2016\\\/05\\\/314_20155153YVSWJE.png\",\"datePublished\":\"2016-05-15T13:18:41+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/#\\\/schema\\\/person\\\/42fb2887449ead82c3023240e547d0ac\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/en\\\/making-code-cleaner\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.baltas.biz\\\/en\\\/making-code-cleaner\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/en\\\/making-code-cleaner\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.baltas.biz\\\/wp-content\\\/uploads\\\/2016\\\/05\\\/314_20155153YVSWJE.png\",\"contentUrl\":\"https:\\\/\\\/www.baltas.biz\\\/wp-content\\\/uploads\\\/2016\\\/05\\\/314_20155153YVSWJE.png\",\"width\":700,\"height\":400},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/en\\\/making-code-cleaner\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.baltas.biz\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Making your code cleaner\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/#website\",\"url\":\"https:\\\/\\\/www.baltas.biz\\\/\",\"name\":\"Baltas\",\"description\":\"Mes kuriame verslo valdymo sistemas, e-parduotuves, interneto svetaines,  interneto puslapi\u0173 dizain\u0105, multimedi\u0105. Mes pri\u017ei\u016brime ir atnaujiname svetaines ir sistemas, atliekame svetaini\u0173 optimizacij\u0105 (SEO). Kuriame lopotipus, prek\u0117s \u017eenklus, reklamos skydelius (banner), aplikacijas soc. tinklams ir t.t.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.baltas.biz\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.baltas.biz\\\/#\\\/schema\\\/person\\\/42fb2887449ead82c3023240e547d0ac\",\"name\":\"baltas\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/036abe811828e2b3bf1376bcbef5813f9e76114ed96f468834992d8db7faf3d6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/036abe811828e2b3bf1376bcbef5813f9e76114ed96f468834992d8db7faf3d6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/036abe811828e2b3bf1376bcbef5813f9e76114ed96f468834992d8db7faf3d6?s=96&d=mm&r=g\",\"caption\":\"baltas\"},\"url\":\"https:\\\/\\\/www.baltas.biz\\\/en\\\/author\\\/baltas\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Making your code cleaner - Baltas","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/","og_locale":"en_US","og_type":"article","og_title":"Making your code cleaner - Baltas","og_description":"I guess that every new programer did double coding one or other time in his career. By double coding i mean, wrote the same code for two different elements. CSS example: \u00a0.class1 { \u00a0 \u00a0margin: 50px auto; \u00a0 \u00a0background-color: white; \u00a0 \u00a0width: 300px; \u00a0 \u00a0text-align: center; \u00a0 \u00a0border: solid 1 px red; \u00a0 \u00a0padding: 15px; [&hellip;]","og_url":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/","og_site_name":"Baltas","article_published_time":"2016-05-15T13:18:41+00:00","og_image":[{"width":700,"height":400,"url":"https:\/\/www.baltas.biz\/wp-content\/uploads\/2016\/05\/314_20155153YVSWJE.png","type":"image\/png"}],"author":"baltas","twitter_card":"summary_large_image","twitter_misc":{"Written by":"baltas","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/#article","isPartOf":{"@id":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/"},"author":{"name":"baltas","@id":"https:\/\/www.baltas.biz\/#\/schema\/person\/42fb2887449ead82c3023240e547d0ac"},"headline":"Making your code cleaner","datePublished":"2016-05-15T13:18:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/"},"wordCount":496,"commentCount":0,"image":{"@id":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/#primaryimage"},"thumbnailUrl":"https:\/\/www.baltas.biz\/wp-content\/uploads\/2016\/05\/314_20155153YVSWJE.png","articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/","url":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/","name":"Making your code cleaner - Baltas","isPartOf":{"@id":"https:\/\/www.baltas.biz\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/#primaryimage"},"image":{"@id":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/#primaryimage"},"thumbnailUrl":"https:\/\/www.baltas.biz\/wp-content\/uploads\/2016\/05\/314_20155153YVSWJE.png","datePublished":"2016-05-15T13:18:41+00:00","author":{"@id":"https:\/\/www.baltas.biz\/#\/schema\/person\/42fb2887449ead82c3023240e547d0ac"},"breadcrumb":{"@id":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.baltas.biz\/en\/making-code-cleaner\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/#primaryimage","url":"https:\/\/www.baltas.biz\/wp-content\/uploads\/2016\/05\/314_20155153YVSWJE.png","contentUrl":"https:\/\/www.baltas.biz\/wp-content\/uploads\/2016\/05\/314_20155153YVSWJE.png","width":700,"height":400},{"@type":"BreadcrumbList","@id":"https:\/\/www.baltas.biz\/en\/making-code-cleaner\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.baltas.biz\/"},{"@type":"ListItem","position":2,"name":"Making your code cleaner"}]},{"@type":"WebSite","@id":"https:\/\/www.baltas.biz\/#website","url":"https:\/\/www.baltas.biz\/","name":"Baltas","description":"Mes kuriame verslo valdymo sistemas, e-parduotuves, interneto svetaines,  interneto puslapi\u0173 dizain\u0105, multimedi\u0105. Mes pri\u017ei\u016brime ir atnaujiname svetaines ir sistemas, atliekame svetaini\u0173 optimizacij\u0105 (SEO). Kuriame lopotipus, prek\u0117s \u017eenklus, reklamos skydelius (banner), aplikacijas soc. tinklams ir t.t.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.baltas.biz\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.baltas.biz\/#\/schema\/person\/42fb2887449ead82c3023240e547d0ac","name":"baltas","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/036abe811828e2b3bf1376bcbef5813f9e76114ed96f468834992d8db7faf3d6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/036abe811828e2b3bf1376bcbef5813f9e76114ed96f468834992d8db7faf3d6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/036abe811828e2b3bf1376bcbef5813f9e76114ed96f468834992d8db7faf3d6?s=96&d=mm&r=g","caption":"baltas"},"url":"https:\/\/www.baltas.biz\/en\/author\/baltas\/"}]}},"_links":{"self":[{"href":"https:\/\/www.baltas.biz\/en\/wp-json\/wp\/v2\/posts\/345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.baltas.biz\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.baltas.biz\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.baltas.biz\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.baltas.biz\/en\/wp-json\/wp\/v2\/comments?post=345"}],"version-history":[{"count":1,"href":"https:\/\/www.baltas.biz\/en\/wp-json\/wp\/v2\/posts\/345\/revisions"}],"predecessor-version":[{"id":347,"href":"https:\/\/www.baltas.biz\/en\/wp-json\/wp\/v2\/posts\/345\/revisions\/347"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.baltas.biz\/en\/wp-json\/wp\/v2\/media\/346"}],"wp:attachment":[{"href":"https:\/\/www.baltas.biz\/en\/wp-json\/wp\/v2\/media?parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.baltas.biz\/en\/wp-json\/wp\/v2\/categories?post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.baltas.biz\/en\/wp-json\/wp\/v2\/tags?post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}