Good practices in development (Use of Float, BRs, Api) [closed]

0

I would like some good practice opinions on development, as I am an amateur in the subject and would like to clarify some doubts.

  • When I'm working on the layout, I use a lot of BR and Floats tags to organize the layout, is this correct or is there better ways? (I had seen it on a website where the developer used a css class that defined width: 100 %, so he could do skip line as the BR tag just by setting this class to the divs)

  • If I use APIs, I started using a yahoo weather forecasting API, it does provide some ways to get the feedback, like php and javascript, which one performs best? I'm using php, but I was not sure if it was doing the api if the site load could be impaired since php runs first and maybe the server waits for the response to continue processing the page.

  • >
    asked by anonymous 12.02.2016 / 12:44

    2 answers

    2

    1- No doubt avoid using BR, use css for this (padding or margin) .. It is a problem to use this kind of tags / css property because if you are doing the template for mobile and desktop you will find problems to put the content in the correct site, this is because the space given is relative to the size of the device that sees the content . In some cases it makes sense to use br if it is a text for example. My advice is to use a framework to understand the basics of content-based authoring, not the device. Examples: link or a more complete and well-known link

    2- I advise two ways:

    • If you want maximum performance in the response time of your site do two actions, one in which the page normally shows (action1) and another one that serves to go to api (action2). Example: I visit the page with content with a load time of 1.5s when finishing this loading, for AJAX make a request to action2, which in turn makes a request to api (for php) This method has the advantage of working only with PHP, taking away the small part of AJAX that makes the request, with this, in my opinion you have more control over everything.
    • The other way is to have only one action, according to the logic above, so you do not have to use JS to place orders. This form is useful if the API is very fast, I usually use this form when the API is mine (it is on the same server) and I do not lose response time

    Hugs and good luck!

        
    12.02.2016 / 13:30
    1

    1) The BR tag skips a line, it's okay to use tag
    but your layout can not be based on skipped lines or not. Try to use CSS for this, preferably create css classes and apply them to the elements instead of using the style attribute in each element of the page, this will make the code easier to maintain and more readable, not to mention the economy of writing and final size. Study margin and padding (CSS), they are correct when you want to distance one thing from the other.

    2) You can use float without problems, it is with yourself that you direct the orientation of the element. But always try to use float in a DIV. Always try to keep your code encapsulated in divs, so you can better control the content and have a better organization.

    3) The consumption of this API is almost irrelevant, because it is a processing off of your page, you only get the result. Now if the API takes time to respond, there is not much to do. Javascript will always be faster than anything when it comes to web, since it is a scripting language already understood by the browser. PHP has its advantages as well as javascript.

    4) Look for separating things, css in the head and script at the bottom of the page inside the body of the page. This way the page is displayed before loading the scritps.

    I strongly suggest you learn HTML, CSS and Javascript first, be good at these 3. When you know javascript for real, you will have a very easy future with web development.

        
    12.02.2016 / 13:12