0

I am trying to create a website. I use Jquery and PHP for server-side and MySQL for database.Now thats one of my PHP files.

//header.php
<div class="d-flex justify-content-start flex-wrap">
<div id="today" class="gal1">today</div>
<div id="history" class="gal1 <?php echo empty( $user ) ? 'mr-auto' : ''; ?>" data-toggle="modal" data-target="#dateModal">history</div>
<?php 
$stmt = $pdo->query("select isSeen from mail where isSeen = 0 and recipient = '$user'");
$lightUp = $stmt->rowCount() > 0 ? 'lightUp' : '';

if ( !empty( $user ) ) echo'<div id="me" class="gal1" onclick="location.href=\'http://localhost:180/anbu/someone.php?someone='.$user.'\'">@'.$user.'</div>
                            <div id="buddy" class="gal1" onclick="location.href=\'http://localhost:180/anbu/subs.php\'">buddy</div>
                            <div id="faves" class="gal1" onclick="location.href=\'http://localhost:180/anbu/faves.php\'">faves</div>
                            <div id="mbox" class="gal1 '.$lightUp.'" onclick="location.href=\'http://localhost:180/anbu/mbox.php\'">mBox</div>
                            <div id="options" class="gal1" onclick="location.href=\'http://localhost:180/anbu/options.php\'">options</div>
                            <div id="eight" class="mr-auto gal1" onclick=""><i class="fa fa-circle" style="color:blue;"></i></div>';

if ( empty( $user ) )  echo'<a class="gal2" href="http://localhost:180/anbu/log-in.php">log in</a>
                            <a class="gal2" href="http://localhost:180/anbu/sign-up.php">sign up</a>';
else
                       echo'<a class="gal2" href="http://localhost:180/anbu/userWorks/log-out.php">log out</a>';
?>

How to compress this code so my server won't have to send all the space characters? Is there a program for this kind of jobs? Yes, my first website and i am a newbie.

6
  • 5
    That's a useless optimization. Commented Mar 22, 2018 at 11:49
  • Just replace two-spaces with single-space. This should not break your code and it will reduce the script size. Commented Mar 22, 2018 at 11:49
  • @ino my codes should be understandable. simplified files will be stored on the server. didn't u get the question? Commented Mar 22, 2018 at 11:52
  • 1
    have your webserver gzip the response payload. For example under apache httpd.apache.org/docs/2.4/mod/mod_deflate.html You then have to weight up CPU vs Bandwidth. Commented Mar 22, 2018 at 11:53
  • @Scuzzy i am buying server today hopefully. Do they have tools? Commented Mar 22, 2018 at 11:54

1 Answer 1

0

Please try to learn any MVC framework for php. Project source code will be unmanageable if you continue writing like this.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.